[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 3/3] staging: atomisp: move mipi_info assignment to next line in __get_asd_from_port()

2017-04-07 Thread Daeseok Youn
The line which is initializing mipi_info variable is too long
to read. It would be placed in next line.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
This series of patches are related to previous patches:
[1] https://lkml.org/lkml/2017/3/27/159
[2] https://lkml.org/lkml/2017/3/30/1068
[3] https://lkml.org/lkml/2017/3/30/1069

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 4af76b5..2208477 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -532,9 +532,11 @@ static void clear_irq_reg(struct atomisp_device *isp)
/* Check which isp subdev to send eof */
for (i = 0; i < isp->num_of_streams; i++) {
struct atomisp_sub_device *asd = >asd[i];
-   struct camera_mipi_info *mipi_info =
-   atomisp_to_sensor_mipi_info(
-   isp->inputs[asd->input_curr].camera);
+   struct camera_mipi_info *mipi_info;
+
+   mipi_info = atomisp_to_sensor_mipi_info(
+   isp->inputs[asd->input_curr].camera);
+
if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
__get_mipi_port(isp, mipi_info->port) == port) {
return asd;
-- 
1.9.1



[PATCH 3/3] staging: atomisp: move mipi_info assignment to next line in __get_asd_from_port()

2017-04-07 Thread Daeseok Youn
The line which is initializing mipi_info variable is too long
to read. It would be placed in next line.

Signed-off-by: Daeseok Youn 
---
This series of patches are related to previous patches:
[1] https://lkml.org/lkml/2017/3/27/159
[2] https://lkml.org/lkml/2017/3/30/1068
[3] https://lkml.org/lkml/2017/3/30/1069

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 4af76b5..2208477 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -532,9 +532,11 @@ static void clear_irq_reg(struct atomisp_device *isp)
/* Check which isp subdev to send eof */
for (i = 0; i < isp->num_of_streams; i++) {
struct atomisp_sub_device *asd = >asd[i];
-   struct camera_mipi_info *mipi_info =
-   atomisp_to_sensor_mipi_info(
-   isp->inputs[asd->input_curr].camera);
+   struct camera_mipi_info *mipi_info;
+
+   mipi_info = atomisp_to_sensor_mipi_info(
+   isp->inputs[asd->input_curr].camera);
+
if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
__get_mipi_port(isp, mipi_info->port) == port) {
return asd;
-- 
1.9.1



[PATCH 2/3] staging: atomisp: replace ">asd[i]" with "asd" in __get_asd_from_port()

2017-04-07 Thread Daeseok Youn
The address of isp->asd[i] is already assigned to
local "asd" variable. ">asd[i]" would be replaced with
just "asd".

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
This series of patches are related to previous patches:
[1] https://lkml.org/lkml/2017/3/27/159
[2] https://lkml.org/lkml/2017/3/30/1068
[3] https://lkml.org/lkml/2017/3/30/1069

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index c3d0596..4af76b5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -535,9 +535,9 @@ static void clear_irq_reg(struct atomisp_device *isp)
struct camera_mipi_info *mipi_info =
atomisp_to_sensor_mipi_info(
isp->inputs[asd->input_curr].camera);
-   if (isp->asd[i].streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
+   if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
__get_mipi_port(isp, mipi_info->port) == port) {
-   return >asd[i];
+   return asd;
}
}
 
-- 
1.9.1



[PATCH 2/3] staging: atomisp: replace ">asd[i]" with "asd" in __get_asd_from_port()

2017-04-07 Thread Daeseok Youn
The address of isp->asd[i] is already assigned to
local "asd" variable. ">asd[i]" would be replaced with
just "asd".

Signed-off-by: Daeseok Youn 
---
This series of patches are related to previous patches:
[1] https://lkml.org/lkml/2017/3/27/159
[2] https://lkml.org/lkml/2017/3/30/1068
[3] https://lkml.org/lkml/2017/3/30/1069

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index c3d0596..4af76b5 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -535,9 +535,9 @@ static void clear_irq_reg(struct atomisp_device *isp)
struct camera_mipi_info *mipi_info =
atomisp_to_sensor_mipi_info(
isp->inputs[asd->input_curr].camera);
-   if (isp->asd[i].streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
+   if (asd->streaming == ATOMISP_DEVICE_STREAMING_ENABLED &&
__get_mipi_port(isp, mipi_info->port) == port) {
-   return >asd[i];
+   return asd;
}
}
 
-- 
1.9.1



[PATCH 1/3] staging: atomisp: remove enable_isp_irq function and add disable_isp_irq

2017-04-07 Thread Daeseok Youn
Enable/Disable ISP irq is switched with "enable" parameter of
enable_isp_irq(). It would be better splited to two such as
enable_isp_irq()/disable_isp_irq().

But the enable_isp_irq() is no use in atomisp_cmd.c file.
So remove the enable_isp_irq() function and add
disable_isp_irq function only.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
This series of patches are related to previous patches:
[1] https://lkml.org/lkml/2017/3/27/159
[2] https://lkml.org/lkml/2017/3/30/1068
[3] https://lkml.org/lkml/2017/3/30/1069

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 36 ++
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 0ba5d8b..c3d0596 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -375,34 +375,16 @@ int atomisp_reset(struct atomisp_device *isp)
 }
 
 /*
- * interrupt enable/disable functions
+ * interrupt disable functions
  */
-static void enable_isp_irq(enum hrt_isp_css_irq irq, bool enable)
-{
-   if (enable) {
-   irq_enable_channel(IRQ0_ID, irq);
-   /*sh_css_hrt_irq_enable(irq, true, false);*/
-   switch (irq) { /*We only have sp interrupt right now*/
-   case hrt_isp_css_irq_sp:
-   /*sh_css_hrt_irq_enable_sp(true);*/
-   cnd_sp_irq_enable(SP0_ID, true);
-   break;
-   default:
-   break;
-   }
+static void disable_isp_irq(enum hrt_isp_css_irq irq)
+{
+   irq_disable_channel(IRQ0_ID, irq);
 
-   } else {
-   /*sh_css_hrt_irq_disable(irq);*/
-   irq_disable_channel(IRQ0_ID, irq);
-   switch (irq) {
-   case hrt_isp_css_irq_sp:
-   /*sh_css_hrt_irq_enable_sp(false);*/
-   cnd_sp_irq_enable(SP0_ID, false);
-   break;
-   default:
-   break;
-   }
-   }
+   if (irq != hrt_isp_css_irq_sp)
+   return;
+
+   cnd_sp_irq_enable(SP0_ID, false);
 }
 
 /*
@@ -1415,7 +1397,7 @@ static void __atomisp_css_recover(struct atomisp_device 
*isp, bool isp_timeout)
}
 
/* clear irq */
-   enable_isp_irq(hrt_isp_css_irq_sp, false);
+   disable_isp_irq(hrt_isp_css_irq_sp);
clear_isp_irq(hrt_isp_css_irq_sp);
 
/* Set the SRSE to 3 before resetting */
-- 
1.9.1



[PATCH 1/3] staging: atomisp: remove enable_isp_irq function and add disable_isp_irq

2017-04-07 Thread Daeseok Youn
Enable/Disable ISP irq is switched with "enable" parameter of
enable_isp_irq(). It would be better splited to two such as
enable_isp_irq()/disable_isp_irq().

But the enable_isp_irq() is no use in atomisp_cmd.c file.
So remove the enable_isp_irq() function and add
disable_isp_irq function only.

Signed-off-by: Daeseok Youn 
---
This series of patches are related to previous patches:
[1] https://lkml.org/lkml/2017/3/27/159
[2] https://lkml.org/lkml/2017/3/30/1068
[3] https://lkml.org/lkml/2017/3/30/1069

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 36 ++
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 0ba5d8b..c3d0596 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -375,34 +375,16 @@ int atomisp_reset(struct atomisp_device *isp)
 }
 
 /*
- * interrupt enable/disable functions
+ * interrupt disable functions
  */
-static void enable_isp_irq(enum hrt_isp_css_irq irq, bool enable)
-{
-   if (enable) {
-   irq_enable_channel(IRQ0_ID, irq);
-   /*sh_css_hrt_irq_enable(irq, true, false);*/
-   switch (irq) { /*We only have sp interrupt right now*/
-   case hrt_isp_css_irq_sp:
-   /*sh_css_hrt_irq_enable_sp(true);*/
-   cnd_sp_irq_enable(SP0_ID, true);
-   break;
-   default:
-   break;
-   }
+static void disable_isp_irq(enum hrt_isp_css_irq irq)
+{
+   irq_disable_channel(IRQ0_ID, irq);
 
-   } else {
-   /*sh_css_hrt_irq_disable(irq);*/
-   irq_disable_channel(IRQ0_ID, irq);
-   switch (irq) {
-   case hrt_isp_css_irq_sp:
-   /*sh_css_hrt_irq_enable_sp(false);*/
-   cnd_sp_irq_enable(SP0_ID, false);
-   break;
-   default:
-   break;
-   }
-   }
+   if (irq != hrt_isp_css_irq_sp)
+   return;
+
+   cnd_sp_irq_enable(SP0_ID, false);
 }
 
 /*
@@ -1415,7 +1397,7 @@ static void __atomisp_css_recover(struct atomisp_device 
*isp, bool isp_timeout)
}
 
/* clear irq */
-   enable_isp_irq(hrt_isp_css_irq_sp, false);
+   disable_isp_irq(hrt_isp_css_irq_sp);
clear_isp_irq(hrt_isp_css_irq_sp);
 
/* Set the SRSE to 3 before resetting */
-- 
1.9.1



[PATCH 2/2 V2] staging: atomisp: use local variable to reduce the number of reference

2017-03-30 Thread Daeseok Youn
Define new local variable to reduce the number of reference.
The new local variable is added to save the addess of dfs
and used in atomisp_freq_scaling() function.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: this patch was rebased since the patch 1/2 was improved.

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 37 --
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 87224d6..9f4041a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 {
/* FIXME! Only use subdev[0] status yet */
struct atomisp_sub_device *asd = >asd[0];
+   const struct atomisp_dfs_config *dfs;
unsigned int new_freq;
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
@@ -264,20 +265,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
if (ATOMISP_IS_CHT(isp) && ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
-   if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
-   isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
-   !isp->dfs->dfs_table) {
+   dfs = isp->dfs;
+
+   if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
+   dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
+   !dfs->dfs_table) {
dev_err(isp->dev, "DFS configuration is invalid.\n");
return -EINVAL;
}
 
if (mode == ATOMISP_DFS_MODE_LOW) {
-   new_freq = isp->dfs->lowest_freq;
+   new_freq = dfs->lowest_freq;
goto done;
}
 
if (mode == ATOMISP_DFS_MODE_MAX) {
-   new_freq = isp->dfs->highest_freq;
+   new_freq = dfs->highest_freq;
goto done;
}
 
@@ -303,26 +306,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
}
 
/* search for the target frequency by looping freq rules*/
-   for (i = 0; i < isp->dfs->dfs_table_size; i++) {
-   if (curr_rules.width != isp->dfs->dfs_table[i].width &&
-   isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
+   for (i = 0; i < dfs->dfs_table_size; i++) {
+   if (curr_rules.width != dfs->dfs_table[i].width &&
+   dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.height != isp->dfs->dfs_table[i].height &&
-   isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
+   if (curr_rules.height != dfs->dfs_table[i].height &&
+   dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
-   isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
+   if (curr_rules.fps != dfs->dfs_table[i].fps &&
+   dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
-   isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
+   if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
+   dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
continue;
break;
}
 
-   if (i == isp->dfs->dfs_table_size)
-   new_freq = isp->dfs->max_freq_at_vmin;
+   if (i == dfs->dfs_table_size)
+   new_freq = dfs->max_freq_at_vmin;
else
-   new_freq = isp->dfs->dfs_table[i].isp_freq;
+   new_freq = dfs->dfs_table[i].isp_freq;
 
 done:
dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);
-- 
2.7.4



[PATCH 2/2 V2] staging: atomisp: use local variable to reduce the number of reference

2017-03-30 Thread Daeseok Youn
Define new local variable to reduce the number of reference.
The new local variable is added to save the addess of dfs
and used in atomisp_freq_scaling() function.

Signed-off-by: Daeseok Youn 
---
V2: this patch was rebased since the patch 1/2 was improved.

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 37 --
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 87224d6..9f4041a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 {
/* FIXME! Only use subdev[0] status yet */
struct atomisp_sub_device *asd = >asd[0];
+   const struct atomisp_dfs_config *dfs;
unsigned int new_freq;
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
@@ -264,20 +265,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
if (ATOMISP_IS_CHT(isp) && ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
-   if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
-   isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
-   !isp->dfs->dfs_table) {
+   dfs = isp->dfs;
+
+   if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
+   dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
+   !dfs->dfs_table) {
dev_err(isp->dev, "DFS configuration is invalid.\n");
return -EINVAL;
}
 
if (mode == ATOMISP_DFS_MODE_LOW) {
-   new_freq = isp->dfs->lowest_freq;
+   new_freq = dfs->lowest_freq;
goto done;
}
 
if (mode == ATOMISP_DFS_MODE_MAX) {
-   new_freq = isp->dfs->highest_freq;
+   new_freq = dfs->highest_freq;
goto done;
}
 
@@ -303,26 +306,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
}
 
/* search for the target frequency by looping freq rules*/
-   for (i = 0; i < isp->dfs->dfs_table_size; i++) {
-   if (curr_rules.width != isp->dfs->dfs_table[i].width &&
-   isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
+   for (i = 0; i < dfs->dfs_table_size; i++) {
+   if (curr_rules.width != dfs->dfs_table[i].width &&
+   dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.height != isp->dfs->dfs_table[i].height &&
-   isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
+   if (curr_rules.height != dfs->dfs_table[i].height &&
+   dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
-   isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
+   if (curr_rules.fps != dfs->dfs_table[i].fps &&
+   dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
-   isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
+   if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
+   dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
continue;
break;
}
 
-   if (i == isp->dfs->dfs_table_size)
-   new_freq = isp->dfs->max_freq_at_vmin;
+   if (i == dfs->dfs_table_size)
+   new_freq = dfs->max_freq_at_vmin;
else
-   new_freq = isp->dfs->dfs_table[i].isp_freq;
+   new_freq = dfs->dfs_table[i].isp_freq;
 
 done:
dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);
-- 
2.7.4



[PATCH 1/2 V2] staging: atomisp: simplify the if condition in atomisp_freq_scaling()

2017-03-30 Thread Daeseok Youn
The condition line in if-statement is needed to be shorthen to
improve readability.

Add a new definition to check the CHT with atomisp_device structure.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: replace the assigment line with macro to check CHT type.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c  | 3 +--
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h | 4 
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..87224d6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -261,8 +261,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
return -EINVAL;
}
 
-   if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
-   ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
+   if (ATOMISP_IS_CHT(isp) && ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
index d366713..97dc5f88 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
@@ -72,6 +72,10 @@
 #define ATOMISP_PCI_DEVICE_SOC_ANN 0x1478
 #define ATOMISP_PCI_DEVICE_SOC_CHT 0x22b8
 
+#define ATOMISP_IS_CHT(isp) \
+   (((isp)->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) == \
+   ATOMISP_PCI_DEVICE_SOC_CHT)
+
 #define ATOMISP_PCI_REV_MRFLD_A0_MAX   0
 #define ATOMISP_PCI_REV_BYT_A0_MAX 4
 
-- 
2.7.4



[PATCH 1/2 V2] staging: atomisp: simplify the if condition in atomisp_freq_scaling()

2017-03-30 Thread Daeseok Youn
The condition line in if-statement is needed to be shorthen to
improve readability.

Add a new definition to check the CHT with atomisp_device structure.

Signed-off-by: Daeseok Youn 
---
V2: replace the assigment line with macro to check CHT type.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c  | 3 +--
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h | 4 
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..87224d6 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -261,8 +261,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
return -EINVAL;
}
 
-   if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
-   ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
+   if (ATOMISP_IS_CHT(isp) && ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
index d366713..97dc5f88 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h
@@ -72,6 +72,10 @@
 #define ATOMISP_PCI_DEVICE_SOC_ANN 0x1478
 #define ATOMISP_PCI_DEVICE_SOC_CHT 0x22b8
 
+#define ATOMISP_IS_CHT(isp) \
+   (((isp)->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) == \
+   ATOMISP_PCI_DEVICE_SOC_CHT)
+
 #define ATOMISP_PCI_REV_MRFLD_A0_MAX   0
 #define ATOMISP_PCI_REV_BYT_A0_MAX 4
 
-- 
2.7.4



Re: [PATCH 1/2] staging: atomisp: simplify the if condition in atomisp_freq_scaling()

2017-03-30 Thread DaeSeok Youn
2017-03-30 19:52 GMT+09:00 Alan Cox <a...@linux.intel.com>:
> On Thu, 2017-03-30 at 15:24 +0900, Daeseok Youn wrote:
>> The condition line in if-statement is needed to be shorthen to
>> improve readability.
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>
> How about a define for ATOMISP_IS_CHT(isp) instead - as we will need
hmm.. I think there is another way to get a *device*(unsigned short or
__u32) to mask with "ATOMISP_PCI_DEVICE_SOC_MASK".
In the atomisp_freq_scaling() function, the "device" value is getting
started from "isp" structure.
(isp->pdev->device)

if the function has only "pci_dev" struction as a parameter and it
need to check the CHT. Then we cannot use the definition like
ATOMISP_IS_CHT(isp). it means we have another definition to check the
CHT.

Am I right?

> these tests in other places where there are ISP2400/ISP2401 ifdefs ?
I am not sure whether these tests are needed in other place or not.
(Actually, I didn't find good H/W reference for Atom ISP device - Can
you please share the link to refer document like H/W manual to
develop?) I have tried to clean up the code first. in the meantime, I
will have a look at the document if I have good reference manual.

Thanks.
Regards,
Daeseok.
>
> Alan
>


Re: [PATCH 1/2] staging: atomisp: simplify the if condition in atomisp_freq_scaling()

2017-03-30 Thread DaeSeok Youn
2017-03-30 19:52 GMT+09:00 Alan Cox :
> On Thu, 2017-03-30 at 15:24 +0900, Daeseok Youn wrote:
>> The condition line in if-statement is needed to be shorthen to
>> improve readability.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>
> How about a define for ATOMISP_IS_CHT(isp) instead - as we will need
hmm.. I think there is another way to get a *device*(unsigned short or
__u32) to mask with "ATOMISP_PCI_DEVICE_SOC_MASK".
In the atomisp_freq_scaling() function, the "device" value is getting
started from "isp" structure.
(isp->pdev->device)

if the function has only "pci_dev" struction as a parameter and it
need to check the CHT. Then we cannot use the definition like
ATOMISP_IS_CHT(isp). it means we have another definition to check the
CHT.

Am I right?

> these tests in other places where there are ISP2400/ISP2401 ifdefs ?
I am not sure whether these tests are needed in other place or not.
(Actually, I didn't find good H/W reference for Atom ISP device - Can
you please share the link to refer document like H/W manual to
develop?) I have tried to clean up the code first. in the meantime, I
will have a look at the document if I have good reference manual.

Thanks.
Regards,
Daeseok.
>
> Alan
>


Re: [PATCH 2/2] staging: atomisp: use local variable to reduce the number of reference

2017-03-30 Thread DaeSeok Youn
2017-03-30 16:19 GMT+09:00 walter harms <wha...@bfs.de>:
>
>
> Am 30.03.2017 08:25, schrieb Daeseok Youn:
>> Define new local variable to reduce the number of reference.
>> The new local variable is added to save the addess of dfs
>> and used in atomisp_freq_scaling() function.
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 37 
>> --
>>  1 file changed, 20 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
>> b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> index eebfccd..d76a95c 100644
>> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> @@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>>  {
>>   /* FIXME! Only use subdev[0] status yet */
>>   struct atomisp_sub_device *asd = >asd[0];
>> + const struct atomisp_dfs_config *dfs;
>>   unsigned int new_freq;
>>   struct atomisp_freq_scaling_rule curr_rules;
>>   int i, ret;
>> @@ -268,20 +269,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>>   ATOMISP_USE_YUVPP(asd))
>>   isp->dfs = _config_cht_soc;
>>
>> - if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
>> - isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
>> - !isp->dfs->dfs_table) {
>> + dfs = isp->dfs;
>> +
>> + if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
>> + dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
>> + !dfs->dfs_table) {
>>   dev_err(isp->dev, "DFS configuration is invalid.\n");
>>   return -EINVAL;
>>   }
>>
>>   if (mode == ATOMISP_DFS_MODE_LOW) {
>> - new_freq = isp->dfs->lowest_freq;
>> + new_freq = dfs->lowest_freq;
>>   goto done;
>>   }
>>
>>   if (mode == ATOMISP_DFS_MODE_MAX) {
>> - new_freq = isp->dfs->highest_freq;
>> + new_freq = dfs->highest_freq;
>>   goto done;
>>   }
>>
>> @@ -307,26 +310,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>>   }
>>
>>   /* search for the target frequency by looping freq rules*/
>> - for (i = 0; i < isp->dfs->dfs_table_size; i++) {
>> - if (curr_rules.width != isp->dfs->dfs_table[i].width &&
>> - isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
>> + for (i = 0; i < dfs->dfs_table_size; i++) {
>> + if (curr_rules.width != dfs->dfs_table[i].width &&
>> + dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
>>   continue;
>> - if (curr_rules.height != isp->dfs->dfs_table[i].height &&
>> - isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
>> + if (curr_rules.height != dfs->dfs_table[i].height &&
>> + dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
>>   continue;
>> - if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
>> - isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
>> + if (curr_rules.fps != dfs->dfs_table[i].fps &&
>> + dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
>>   continue;
>> - if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
>> - isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
>> + if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
>> + dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
>>   continue;
>>   break;
>>   }
>
>>
>> - if (i == isp->dfs->dfs_table_size)
>> - new_freq = isp->dfs->max_freq_at_vmin;
>> + if (i == dfs->dfs_table_size)
>> + new_freq = dfs->max_freq_at_vmin;
>>   else
>> - new_freq = isp->dfs->dfs_table[i].isp_freq;
>> + new_freq = dfs->dfs_table[i].isp_freq;
>>
>
> you can eliminate the last block by setting
>
>  new_freq = dfs->max_freq_at_vmin;
>
>   for(i=0;) {
> 
> new_freq = dfs->dfs_table[i].isp_freq;
> break;
> }
Yes, it could be. I will make another patch to improve it as your comment.
>
> unfortunately i have no good idea how to make the loop more readable.
I am not sure whether the for-loop is possible to improve for
readability or not. :-)

Thanks for comment.
Regards,
Daeseok.
>
>
> re,
>  wh
>
>
>>  done:
>>   dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);


Re: [PATCH 2/2] staging: atomisp: use local variable to reduce the number of reference

2017-03-30 Thread DaeSeok Youn
2017-03-30 16:19 GMT+09:00 walter harms :
>
>
> Am 30.03.2017 08:25, schrieb Daeseok Youn:
>> Define new local variable to reduce the number of reference.
>> The new local variable is added to save the addess of dfs
>> and used in atomisp_freq_scaling() function.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 37 
>> --
>>  1 file changed, 20 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
>> b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> index eebfccd..d76a95c 100644
>> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> @@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>>  {
>>   /* FIXME! Only use subdev[0] status yet */
>>   struct atomisp_sub_device *asd = >asd[0];
>> + const struct atomisp_dfs_config *dfs;
>>   unsigned int new_freq;
>>   struct atomisp_freq_scaling_rule curr_rules;
>>   int i, ret;
>> @@ -268,20 +269,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>>   ATOMISP_USE_YUVPP(asd))
>>   isp->dfs = _config_cht_soc;
>>
>> - if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
>> - isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
>> - !isp->dfs->dfs_table) {
>> + dfs = isp->dfs;
>> +
>> + if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
>> + dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
>> + !dfs->dfs_table) {
>>   dev_err(isp->dev, "DFS configuration is invalid.\n");
>>   return -EINVAL;
>>   }
>>
>>   if (mode == ATOMISP_DFS_MODE_LOW) {
>> - new_freq = isp->dfs->lowest_freq;
>> + new_freq = dfs->lowest_freq;
>>   goto done;
>>   }
>>
>>   if (mode == ATOMISP_DFS_MODE_MAX) {
>> - new_freq = isp->dfs->highest_freq;
>> + new_freq = dfs->highest_freq;
>>   goto done;
>>   }
>>
>> @@ -307,26 +310,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
>>   }
>>
>>   /* search for the target frequency by looping freq rules*/
>> - for (i = 0; i < isp->dfs->dfs_table_size; i++) {
>> - if (curr_rules.width != isp->dfs->dfs_table[i].width &&
>> - isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
>> + for (i = 0; i < dfs->dfs_table_size; i++) {
>> + if (curr_rules.width != dfs->dfs_table[i].width &&
>> + dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
>>   continue;
>> - if (curr_rules.height != isp->dfs->dfs_table[i].height &&
>> - isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
>> + if (curr_rules.height != dfs->dfs_table[i].height &&
>> + dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
>>   continue;
>> - if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
>> - isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
>> + if (curr_rules.fps != dfs->dfs_table[i].fps &&
>> + dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
>>   continue;
>> - if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
>> - isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
>> + if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
>> + dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
>>   continue;
>>   break;
>>   }
>
>>
>> - if (i == isp->dfs->dfs_table_size)
>> - new_freq = isp->dfs->max_freq_at_vmin;
>> + if (i == dfs->dfs_table_size)
>> + new_freq = dfs->max_freq_at_vmin;
>>   else
>> - new_freq = isp->dfs->dfs_table[i].isp_freq;
>> + new_freq = dfs->dfs_table[i].isp_freq;
>>
>
> you can eliminate the last block by setting
>
>  new_freq = dfs->max_freq_at_vmin;
>
>   for(i=0;) {
> 
> new_freq = dfs->dfs_table[i].isp_freq;
> break;
> }
Yes, it could be. I will make another patch to improve it as your comment.
>
> unfortunately i have no good idea how to make the loop more readable.
I am not sure whether the for-loop is possible to improve for
readability or not. :-)

Thanks for comment.
Regards,
Daeseok.
>
>
> re,
>  wh
>
>
>>  done:
>>   dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);


[PATCH 2/2] staging: atomisp: use local variable to reduce the number of reference

2017-03-30 Thread Daeseok Youn
Define new local variable to reduce the number of reference.
The new local variable is added to save the addess of dfs
and used in atomisp_freq_scaling() function.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 37 --
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index eebfccd..d76a95c 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 {
/* FIXME! Only use subdev[0] status yet */
struct atomisp_sub_device *asd = >asd[0];
+   const struct atomisp_dfs_config *dfs;
unsigned int new_freq;
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
@@ -268,20 +269,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
-   if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
-   isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
-   !isp->dfs->dfs_table) {
+   dfs = isp->dfs;
+
+   if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
+   dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
+   !dfs->dfs_table) {
dev_err(isp->dev, "DFS configuration is invalid.\n");
return -EINVAL;
}
 
if (mode == ATOMISP_DFS_MODE_LOW) {
-   new_freq = isp->dfs->lowest_freq;
+   new_freq = dfs->lowest_freq;
goto done;
}
 
if (mode == ATOMISP_DFS_MODE_MAX) {
-   new_freq = isp->dfs->highest_freq;
+   new_freq = dfs->highest_freq;
goto done;
}
 
@@ -307,26 +310,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
}
 
/* search for the target frequency by looping freq rules*/
-   for (i = 0; i < isp->dfs->dfs_table_size; i++) {
-   if (curr_rules.width != isp->dfs->dfs_table[i].width &&
-   isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
+   for (i = 0; i < dfs->dfs_table_size; i++) {
+   if (curr_rules.width != dfs->dfs_table[i].width &&
+   dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.height != isp->dfs->dfs_table[i].height &&
-   isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
+   if (curr_rules.height != dfs->dfs_table[i].height &&
+   dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
-   isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
+   if (curr_rules.fps != dfs->dfs_table[i].fps &&
+   dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
-   isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
+   if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
+   dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
continue;
break;
}
 
-   if (i == isp->dfs->dfs_table_size)
-   new_freq = isp->dfs->max_freq_at_vmin;
+   if (i == dfs->dfs_table_size)
+   new_freq = dfs->max_freq_at_vmin;
else
-   new_freq = isp->dfs->dfs_table[i].isp_freq;
+   new_freq = dfs->dfs_table[i].isp_freq;
 
 done:
dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);
-- 
1.9.1



[PATCH 2/2] staging: atomisp: use local variable to reduce the number of reference

2017-03-30 Thread Daeseok Youn
Define new local variable to reduce the number of reference.
The new local variable is added to save the addess of dfs
and used in atomisp_freq_scaling() function.

Signed-off-by: Daeseok Youn 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 37 --
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index eebfccd..d76a95c 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -251,6 +251,7 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
 {
/* FIXME! Only use subdev[0] status yet */
struct atomisp_sub_device *asd = >asd[0];
+   const struct atomisp_dfs_config *dfs;
unsigned int new_freq;
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
@@ -268,20 +269,22 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
-   if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
-   isp->dfs->highest_freq == 0 || isp->dfs->dfs_table_size == 0 ||
-   !isp->dfs->dfs_table) {
+   dfs = isp->dfs;
+
+   if (dfs->lowest_freq == 0 || dfs->max_freq_at_vmin == 0 ||
+   dfs->highest_freq == 0 || dfs->dfs_table_size == 0 ||
+   !dfs->dfs_table) {
dev_err(isp->dev, "DFS configuration is invalid.\n");
return -EINVAL;
}
 
if (mode == ATOMISP_DFS_MODE_LOW) {
-   new_freq = isp->dfs->lowest_freq;
+   new_freq = dfs->lowest_freq;
goto done;
}
 
if (mode == ATOMISP_DFS_MODE_MAX) {
-   new_freq = isp->dfs->highest_freq;
+   new_freq = dfs->highest_freq;
goto done;
}
 
@@ -307,26 +310,26 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
}
 
/* search for the target frequency by looping freq rules*/
-   for (i = 0; i < isp->dfs->dfs_table_size; i++) {
-   if (curr_rules.width != isp->dfs->dfs_table[i].width &&
-   isp->dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
+   for (i = 0; i < dfs->dfs_table_size; i++) {
+   if (curr_rules.width != dfs->dfs_table[i].width &&
+   dfs->dfs_table[i].width != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.height != isp->dfs->dfs_table[i].height &&
-   isp->dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
+   if (curr_rules.height != dfs->dfs_table[i].height &&
+   dfs->dfs_table[i].height != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.fps != isp->dfs->dfs_table[i].fps &&
-   isp->dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
+   if (curr_rules.fps != dfs->dfs_table[i].fps &&
+   dfs->dfs_table[i].fps != ISP_FREQ_RULE_ANY)
continue;
-   if (curr_rules.run_mode != isp->dfs->dfs_table[i].run_mode &&
-   isp->dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
+   if (curr_rules.run_mode != dfs->dfs_table[i].run_mode &&
+   dfs->dfs_table[i].run_mode != ISP_FREQ_RULE_ANY)
continue;
break;
}
 
-   if (i == isp->dfs->dfs_table_size)
-   new_freq = isp->dfs->max_freq_at_vmin;
+   if (i == dfs->dfs_table_size)
+   new_freq = dfs->max_freq_at_vmin;
else
-   new_freq = isp->dfs->dfs_table[i].isp_freq;
+   new_freq = dfs->dfs_table[i].isp_freq;
 
 done:
dev_dbg(isp->dev, "DFS target frequency=%d.\n", new_freq);
-- 
1.9.1



[PATCH 1/2] staging: atomisp: simplify the if condition in atomisp_freq_scaling()

2017-03-30 Thread Daeseok Youn
The condition line in if-statement is needed to be shorthen to
improve readability.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..eebfccd 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -255,14 +255,17 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
unsigned short fps = 0;
+   unsigned short masked_dev = 0;
 
if (isp->sw_contex.power_state != ATOM_ISP_POWER_UP) {
dev_err(isp->dev, "DFS cannot proceed due to no power.\n");
return -EINVAL;
}
 
-   if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
-   ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
+   masked_dev = isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK;
+
+   if (masked_dev == ATOMISP_PCI_DEVICE_SOC_CHT &&
+   ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
-- 
1.9.1



[PATCH 1/2] staging: atomisp: simplify the if condition in atomisp_freq_scaling()

2017-03-30 Thread Daeseok Youn
The condition line in if-statement is needed to be shorthen to
improve readability.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..eebfccd 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -255,14 +255,17 @@ int atomisp_freq_scaling(struct atomisp_device *isp,
struct atomisp_freq_scaling_rule curr_rules;
int i, ret;
unsigned short fps = 0;
+   unsigned short masked_dev = 0;
 
if (isp->sw_contex.power_state != ATOM_ISP_POWER_UP) {
dev_err(isp->dev, "DFS cannot proceed due to no power.\n");
return -EINVAL;
}
 
-   if ((isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK) ==
-   ATOMISP_PCI_DEVICE_SOC_CHT && ATOMISP_USE_YUVPP(asd))
+   masked_dev = isp->pdev->device & ATOMISP_PCI_DEVICE_SOC_MASK;
+
+   if (masked_dev == ATOMISP_PCI_DEVICE_SOC_CHT &&
+   ATOMISP_USE_YUVPP(asd))
isp->dfs = _config_cht_soc;
 
if (isp->dfs->lowest_freq == 0 || isp->dfs->max_freq_at_vmin == 0 ||
-- 
1.9.1



[PATCH] staging: atomisp: fix an issue timeout value for checking error

2017-03-27 Thread Daeseok Youn
The timeout variable could be zero even if the bits has expected result.
The checking expected bits again would be better instead whether
the timeout value is zero or not.

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

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..f2e5749 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -220,11 +220,11 @@ static int write_target_freq_to_hw(struct atomisp_device 
*isp,
timeout--;
}
 
-   if (timeout != 0)
+   if (!(isp_sspm1 & ISP_FREQ_VALID_MASK))
break;
}
 
-   if (timeout == 0) {
+   if (isp_sspm1 & ISP_FREQ_VALID_MASK) {
dev_err(isp->dev, "DFS failed due to HW error.\n");
return -EINVAL;
}
@@ -238,7 +238,7 @@ static int write_target_freq_to_hw(struct atomisp_device 
*isp,
udelay(100);
timeout--;
}
-   if (timeout == 0) {
+   if ((isp_sspm1 >> ISP_FREQ_STAT_OFFSET) != ratio) {
dev_err(isp->dev, "DFS target freq is rejected by HW.\n");
return -EINVAL;
}
-- 
1.9.1



[PATCH] staging: atomisp: fix an issue timeout value for checking error

2017-03-27 Thread Daeseok Youn
The timeout variable could be zero even if the bits has expected result.
The checking expected bits again would be better instead whether
the timeout value is zero or not.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 94bc793..f2e5749 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -220,11 +220,11 @@ static int write_target_freq_to_hw(struct atomisp_device 
*isp,
timeout--;
}
 
-   if (timeout != 0)
+   if (!(isp_sspm1 & ISP_FREQ_VALID_MASK))
break;
}
 
-   if (timeout == 0) {
+   if (isp_sspm1 & ISP_FREQ_VALID_MASK) {
dev_err(isp->dev, "DFS failed due to HW error.\n");
return -EINVAL;
}
@@ -238,7 +238,7 @@ static int write_target_freq_to_hw(struct atomisp_device 
*isp,
udelay(100);
timeout--;
}
-   if (timeout == 0) {
+   if ((isp_sspm1 >> ISP_FREQ_STAT_OFFSET) != ratio) {
dev_err(isp->dev, "DFS target freq is rejected by HW.\n");
return -EINVAL;
}
-- 
1.9.1



[PATCH 4/4 V2] staging: atomisp: remove redudant condition in if-statement

2017-03-20 Thread Daeseok Youn
The V4L2_FIELD_ANY is zero, so the (!field) is same meaning
with (field == V4L2_FIELD_ANY) in if-statement.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: one(2/4) of this series was updated so I tried to send them again.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index f7c0705..943a7ae 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -5084,7 +5084,7 @@ int atomisp_try_fmt(struct video_device *vdev, struct 
v4l2_format *f,
 
depth = get_pixel_depth(pixelformat);
 
-   if (!field || field == V4L2_FIELD_ANY)
+   if (field == V4L2_FIELD_ANY)
field = V4L2_FIELD_NONE;
else if (field != V4L2_FIELD_NONE) {
dev_err(isp->dev, "Wrong output field\n");
-- 
1.9.1



[PATCH 4/4 V2] staging: atomisp: remove redudant condition in if-statement

2017-03-20 Thread Daeseok Youn
The V4L2_FIELD_ANY is zero, so the (!field) is same meaning
with (field == V4L2_FIELD_ANY) in if-statement.

Signed-off-by: Daeseok Youn 
---
V2: one(2/4) of this series was updated so I tried to send them again.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index f7c0705..943a7ae 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -5084,7 +5084,7 @@ int atomisp_try_fmt(struct video_device *vdev, struct 
v4l2_format *f,
 
depth = get_pixel_depth(pixelformat);
 
-   if (!field || field == V4L2_FIELD_ANY)
+   if (field == V4L2_FIELD_ANY)
field = V4L2_FIELD_NONE;
else if (field != V4L2_FIELD_NONE) {
dev_err(isp->dev, "Wrong output field\n");
-- 
1.9.1



[PATCH 3/4 V2] staging: atomisp: remove useless condition in if-statements

2017-03-20 Thread Daeseok Youn
The css_pipe_id was checked with 'CSS_PIPE_ID_COPY' in previous if-
statement. In this case, if the css_pipe_id equals to 'CSS_PIPE_ID_COPY',
it could not enter the next if-statement. But the "next" if-statement
has the condition to check whether the css_pipe_id equals to
'CSS_PIPE_ID_COPY' or not. It should be removed.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: one(2/4) of this series was updated so I tried to send them again.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 811331d..f7c0705 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -910,8 +910,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
/* For online video or SDV video pipe. */
if (css_pipe_id == CSS_PIPE_ID_VIDEO ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP) {
+   css_pipe_id == CSS_PIPE_ID_COPY) {
if (buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
return >video_out_video_capture;
return >video_out_preview;
@@ -919,8 +918,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
/* For online preview or ZSL preview pipe. */
if (css_pipe_id == CSS_PIPE_ID_PREVIEW ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP)
+   css_pipe_id == CSS_PIPE_ID_COPY)
return >video_out_preview;
}
/* For capture pipe. */
-- 
1.9.1



[PATCH 3/4 V2] staging: atomisp: remove useless condition in if-statements

2017-03-20 Thread Daeseok Youn
The css_pipe_id was checked with 'CSS_PIPE_ID_COPY' in previous if-
statement. In this case, if the css_pipe_id equals to 'CSS_PIPE_ID_COPY',
it could not enter the next if-statement. But the "next" if-statement
has the condition to check whether the css_pipe_id equals to
'CSS_PIPE_ID_COPY' or not. It should be removed.

Signed-off-by: Daeseok Youn 
---
V2: one(2/4) of this series was updated so I tried to send them again.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 811331d..f7c0705 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -910,8 +910,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
/* For online video or SDV video pipe. */
if (css_pipe_id == CSS_PIPE_ID_VIDEO ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP) {
+   css_pipe_id == CSS_PIPE_ID_COPY) {
if (buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
return >video_out_video_capture;
return >video_out_preview;
@@ -919,8 +918,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
/* For online preview or ZSL preview pipe. */
if (css_pipe_id == CSS_PIPE_ID_PREVIEW ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP)
+   css_pipe_id == CSS_PIPE_ID_COPY)
return >video_out_preview;
}
/* For capture pipe. */
-- 
1.9.1



[PATCH 2/4 V2] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread Daeseok Youn
If v4l2_subdev_call() gets the global frame interval values,
it returned 0 and it could be checked whether numerator is zero or not.

If the numerator is not zero, the fps could be calculated in this function.
If not, it just returns 0.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: split error handling, the first check is for the result from 
v4l2_subdev_call(),
another check is for fi.interval.numerator > 0. it is more understandable 
and
simpler than before.

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 24 ++
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 8bdb224..811331d 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -153,21 +153,19 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
video_device *dev)
 
 static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
 {
-   struct v4l2_subdev_frame_interval frame_interval;
+   struct v4l2_subdev_frame_interval fi;
struct atomisp_device *isp = asd->isp;
-   unsigned short fps;
 
-   if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-   video, g_frame_interval, _interval)) {
-   fps = 0;
-   } else {
-   if (frame_interval.interval.numerator)
-   fps = frame_interval.interval.denominator /
-   frame_interval.interval.numerator;
-   else
-   fps = 0;
-   }
-   return fps;
+   int ret;
+
+   ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+  video, g_frame_interval, );
+
+   if (ret)
+   return 0;
+
+   return (fi.interval.numerator > 0) ?
+  (fi.interval.denominator / fi.interval.numerator) : 0;
 }
 
 /*
-- 
1.9.1



[PATCH 2/4 V2] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread Daeseok Youn
If v4l2_subdev_call() gets the global frame interval values,
it returned 0 and it could be checked whether numerator is zero or not.

If the numerator is not zero, the fps could be calculated in this function.
If not, it just returns 0.

Signed-off-by: Daeseok Youn 
---
V2: split error handling, the first check is for the result from 
v4l2_subdev_call(),
another check is for fi.interval.numerator > 0. it is more understandable 
and
simpler than before.

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 24 ++
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 8bdb224..811331d 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -153,21 +153,19 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
video_device *dev)
 
 static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
 {
-   struct v4l2_subdev_frame_interval frame_interval;
+   struct v4l2_subdev_frame_interval fi;
struct atomisp_device *isp = asd->isp;
-   unsigned short fps;
 
-   if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-   video, g_frame_interval, _interval)) {
-   fps = 0;
-   } else {
-   if (frame_interval.interval.numerator)
-   fps = frame_interval.interval.denominator /
-   frame_interval.interval.numerator;
-   else
-   fps = 0;
-   }
-   return fps;
+   int ret;
+
+   ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+  video, g_frame_interval, );
+
+   if (ret)
+   return 0;
+
+   return (fi.interval.numerator > 0) ?
+  (fi.interval.denominator / fi.interval.numerator) : 0;
 }
 
 /*
-- 
1.9.1



[PATCH 1/4 V2] staging: atomisp: remove else statement after return

2017-03-20 Thread Daeseok Youn
It doesn't need to have else statement after return.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: one(2/4) of this series was updated so I tried to send them again.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index d97a8df..8bdb224 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -2958,11 +2958,11 @@ int atomisp_get_metadata(struct atomisp_sub_device 
*asd, int flag,
dev_err(isp->dev, "copy to user failed: copied %d bytes\n",
ret);
return -EFAULT;
-   } else {
-   list_del_init(_buf->list);
-   list_add_tail(_buf->list, >metadata[md_type]);
}
 
+   list_del_init(_buf->list);
+   list_add_tail(_buf->list, >metadata[md_type]);
+
dev_dbg(isp->dev, "%s: HAL de-queued metadata type %d with exp_id %d\n",
__func__, md_type, md->exp_id);
return 0;
-- 
1.9.1



[PATCH 1/4 V2] staging: atomisp: remove else statement after return

2017-03-20 Thread Daeseok Youn
It doesn't need to have else statement after return.

Signed-off-by: Daeseok Youn 
---
V2: one(2/4) of this series was updated so I tried to send them again.

 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index d97a8df..8bdb224 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -2958,11 +2958,11 @@ int atomisp_get_metadata(struct atomisp_sub_device 
*asd, int flag,
dev_err(isp->dev, "copy to user failed: copied %d bytes\n",
ret);
return -EFAULT;
-   } else {
-   list_del_init(_buf->list);
-   list_add_tail(_buf->list, >metadata[md_type]);
}
 
+   list_del_init(_buf->list);
+   list_add_tail(_buf->list, >metadata[md_type]);
+
dev_dbg(isp->dev, "%s: HAL de-queued metadata type %d with exp_id %d\n",
__func__, md_type, md->exp_id);
return 0;
-- 
1.9.1



Re: [PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread DaeSeok Youn
2017-03-20 22:11 GMT+09:00 walter harms <wha...@bfs.de>:
>
>
> Am 20.03.2017 13:51, schrieb DaeSeok Youn:
>> 2017-03-20 21:04 GMT+09:00 walter harms <wha...@bfs.de>:
>>>
>>>
>>> Am 20.03.2017 11:59, schrieb Daeseok Youn:
>>>> If v4l2_subdev_call() gets the global frame interval values,
>>>> it returned 0 and it could be checked whether numerator is zero or not.
>>>>
>>>> If the numerator is not zero, the fps could be calculated in this function.
>>>> If not, it just returns 0.
>>>>
>>>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>>>> ---
>>>>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 22 
>>>> ++
>>>>  1 file changed, 10 insertions(+), 12 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
>>>> b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>>>> index 8bdb224..6bdd19e 100644
>>>> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>>>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>>>> @@ -153,20 +153,18 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
>>>> video_device *dev)
>>>>
>>>>  static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device 
>>>> *asd)
>>>>  {
>>>> - struct v4l2_subdev_frame_interval frame_interval;
>>>> + struct v4l2_subdev_frame_interval fi;
>>>>   struct atomisp_device *isp = asd->isp;
>>>> - unsigned short fps;
>>>>
>>>> - if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>>>> - video, g_frame_interval, _interval)) {
>>>> - fps = 0;
>>>> - } else {
>>>> - if (frame_interval.interval.numerator)
>>>> - fps = frame_interval.interval.denominator /
>>>> - frame_interval.interval.numerator;
>>>> - else
>>>> - fps = 0;
>>>> - }
>>>> + unsigned short fps = 0;
>>>> + int ret;
>>>> +
>>>> + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>>>> +video, g_frame_interval, );
>>>> +
>>>> + if (!ret && fi.interval.numerator)
>>>> + fps = fi.interval.denominator / fi.interval.numerator;
>>>> +
>>>>   return fps;
>>>>  }
>>>
>>>
>>>
>>> do you need to check ret at all ? if an error occurs can 
>>> fi.interval.numerator
>>> be something else than 0 ?
>> the return value from the v4l2_subdev_call() function is zero when it
>> is done without any error. and also I checked
>> the ret value whether is 0 or not. if the ret is 0 then the value of
>> numerator should be checked to avoid for dividing by 0.
>>>
>>> if ret is an ERRNO it would be wise to return ret not fps, but this may 
>>> require
>>> changes at other places also.
>> hmm.., yes, you are right. but I think it is ok because the
>> atomisp_get_sensor_fps() function is needed to get fps value.
>> (originally, zero or calculated fps value was returned.)
>
> maybe its better to divide this in:
> if (ret)
>return 0; // error case
>
> return (fi.interval.numerator>0)?fi.interval.denominator / 
> fi.interval.numerator:0;
>
> So there is a chance that someone will a) understand and b) fix the error 
> return.
yes, it looks better than mine. I will update it and resend it.

Thanks walter,
Regards,
Daeseok Youn.

>
> re,
>  wh
>
>>
>>>
>>> re,
>>>  wh
>>>
>>>>
>>


Re: [PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread DaeSeok Youn
2017-03-20 22:11 GMT+09:00 walter harms :
>
>
> Am 20.03.2017 13:51, schrieb DaeSeok Youn:
>> 2017-03-20 21:04 GMT+09:00 walter harms :
>>>
>>>
>>> Am 20.03.2017 11:59, schrieb Daeseok Youn:
>>>> If v4l2_subdev_call() gets the global frame interval values,
>>>> it returned 0 and it could be checked whether numerator is zero or not.
>>>>
>>>> If the numerator is not zero, the fps could be calculated in this function.
>>>> If not, it just returns 0.
>>>>
>>>> Signed-off-by: Daeseok Youn 
>>>> ---
>>>>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 22 
>>>> ++
>>>>  1 file changed, 10 insertions(+), 12 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
>>>> b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>>>> index 8bdb224..6bdd19e 100644
>>>> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>>>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>>>> @@ -153,20 +153,18 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
>>>> video_device *dev)
>>>>
>>>>  static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device 
>>>> *asd)
>>>>  {
>>>> - struct v4l2_subdev_frame_interval frame_interval;
>>>> + struct v4l2_subdev_frame_interval fi;
>>>>   struct atomisp_device *isp = asd->isp;
>>>> - unsigned short fps;
>>>>
>>>> - if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>>>> - video, g_frame_interval, _interval)) {
>>>> - fps = 0;
>>>> - } else {
>>>> - if (frame_interval.interval.numerator)
>>>> - fps = frame_interval.interval.denominator /
>>>> - frame_interval.interval.numerator;
>>>> - else
>>>> - fps = 0;
>>>> - }
>>>> + unsigned short fps = 0;
>>>> + int ret;
>>>> +
>>>> + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>>>> +video, g_frame_interval, );
>>>> +
>>>> + if (!ret && fi.interval.numerator)
>>>> + fps = fi.interval.denominator / fi.interval.numerator;
>>>> +
>>>>   return fps;
>>>>  }
>>>
>>>
>>>
>>> do you need to check ret at all ? if an error occurs can 
>>> fi.interval.numerator
>>> be something else than 0 ?
>> the return value from the v4l2_subdev_call() function is zero when it
>> is done without any error. and also I checked
>> the ret value whether is 0 or not. if the ret is 0 then the value of
>> numerator should be checked to avoid for dividing by 0.
>>>
>>> if ret is an ERRNO it would be wise to return ret not fps, but this may 
>>> require
>>> changes at other places also.
>> hmm.., yes, you are right. but I think it is ok because the
>> atomisp_get_sensor_fps() function is needed to get fps value.
>> (originally, zero or calculated fps value was returned.)
>
> maybe its better to divide this in:
> if (ret)
>return 0; // error case
>
> return (fi.interval.numerator>0)?fi.interval.denominator / 
> fi.interval.numerator:0;
>
> So there is a chance that someone will a) understand and b) fix the error 
> return.
yes, it looks better than mine. I will update it and resend it.

Thanks walter,
Regards,
Daeseok Youn.

>
> re,
>  wh
>
>>
>>>
>>> re,
>>>  wh
>>>
>>>>
>>


Re: [PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread DaeSeok Youn
2017-03-20 21:04 GMT+09:00 walter harms <wha...@bfs.de>:
>
>
> Am 20.03.2017 11:59, schrieb Daeseok Youn:
>> If v4l2_subdev_call() gets the global frame interval values,
>> it returned 0 and it could be checked whether numerator is zero or not.
>>
>> If the numerator is not zero, the fps could be calculated in this function.
>> If not, it just returns 0.
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 22 
>> ++
>>  1 file changed, 10 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
>> b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> index 8bdb224..6bdd19e 100644
>> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> @@ -153,20 +153,18 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
>> video_device *dev)
>>
>>  static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
>>  {
>> - struct v4l2_subdev_frame_interval frame_interval;
>> + struct v4l2_subdev_frame_interval fi;
>>   struct atomisp_device *isp = asd->isp;
>> - unsigned short fps;
>>
>> - if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>> - video, g_frame_interval, _interval)) {
>> - fps = 0;
>> - } else {
>> - if (frame_interval.interval.numerator)
>> - fps = frame_interval.interval.denominator /
>> - frame_interval.interval.numerator;
>> - else
>> - fps = 0;
>> - }
>> + unsigned short fps = 0;
>> + int ret;
>> +
>> + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>> +video, g_frame_interval, );
>> +
>> + if (!ret && fi.interval.numerator)
>> + fps = fi.interval.denominator / fi.interval.numerator;
>> +
>>   return fps;
>>  }
>
>
>
> do you need to check ret at all ? if an error occurs can fi.interval.numerator
> be something else than 0 ?
the return value from the v4l2_subdev_call() function is zero when it
is done without any error. and also I checked
the ret value whether is 0 or not. if the ret is 0 then the value of
numerator should be checked to avoid for dividing by 0.
>
> if ret is an ERRNO it would be wise to return ret not fps, but this may 
> require
> changes at other places also.
hmm.., yes, you are right. but I think it is ok because the
atomisp_get_sensor_fps() function is needed to get fps value.
(originally, zero or calculated fps value was returned.)

>
> re,
>  wh
>
>>


Re: [PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread DaeSeok Youn
2017-03-20 21:04 GMT+09:00 walter harms :
>
>
> Am 20.03.2017 11:59, schrieb Daeseok Youn:
>> If v4l2_subdev_call() gets the global frame interval values,
>> it returned 0 and it could be checked whether numerator is zero or not.
>>
>> If the numerator is not zero, the fps could be calculated in this function.
>> If not, it just returns 0.
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 22 
>> ++
>>  1 file changed, 10 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
>> b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> index 8bdb224..6bdd19e 100644
>> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
>> @@ -153,20 +153,18 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
>> video_device *dev)
>>
>>  static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
>>  {
>> - struct v4l2_subdev_frame_interval frame_interval;
>> + struct v4l2_subdev_frame_interval fi;
>>   struct atomisp_device *isp = asd->isp;
>> - unsigned short fps;
>>
>> - if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>> - video, g_frame_interval, _interval)) {
>> - fps = 0;
>> - } else {
>> - if (frame_interval.interval.numerator)
>> - fps = frame_interval.interval.denominator /
>> - frame_interval.interval.numerator;
>> - else
>> - fps = 0;
>> - }
>> + unsigned short fps = 0;
>> + int ret;
>> +
>> + ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
>> +video, g_frame_interval, );
>> +
>> + if (!ret && fi.interval.numerator)
>> + fps = fi.interval.denominator / fi.interval.numerator;
>> +
>>   return fps;
>>  }
>
>
>
> do you need to check ret at all ? if an error occurs can fi.interval.numerator
> be something else than 0 ?
the return value from the v4l2_subdev_call() function is zero when it
is done without any error. and also I checked
the ret value whether is 0 or not. if the ret is 0 then the value of
numerator should be checked to avoid for dividing by 0.
>
> if ret is an ERRNO it would be wise to return ret not fps, but this may 
> require
> changes at other places also.
hmm.., yes, you are right. but I think it is ok because the
atomisp_get_sensor_fps() function is needed to get fps value.
(originally, zero or calculated fps value was returned.)

>
> re,
>  wh
>
>>


[PATCH 3/4] staging: atomisp: remove useless condition in if-statements

2017-03-20 Thread Daeseok Youn
The css_pipe_id was checked with 'CSS_PIPE_ID_COPY' in previous if-
statement. In this case, if the css_pipe_id equals to 'CSS_PIPE_ID_COPY',
it could not enter the next if-statement. But the "next" if-statement
has the condition to check whether the css_pipe_id equals to
'CSS_PIPE_ID_COPY' or not. It should be removed.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 6bdd19e..929ed80 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -910,8 +910,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
/* For online video or SDV video pipe. */
if (css_pipe_id == CSS_PIPE_ID_VIDEO ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP) {
+   css_pipe_id == CSS_PIPE_ID_COPY) {
if (buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
return >video_out_video_capture;
return >video_out_preview;
@@ -919,8 +918,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
/* For online preview or ZSL preview pipe. */
if (css_pipe_id == CSS_PIPE_ID_PREVIEW ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP)
+   css_pipe_id == CSS_PIPE_ID_COPY)
return >video_out_preview;
}
/* For capture pipe. */
-- 
1.9.1



[PATCH 3/4] staging: atomisp: remove useless condition in if-statements

2017-03-20 Thread Daeseok Youn
The css_pipe_id was checked with 'CSS_PIPE_ID_COPY' in previous if-
statement. In this case, if the css_pipe_id equals to 'CSS_PIPE_ID_COPY',
it could not enter the next if-statement. But the "next" if-statement
has the condition to check whether the css_pipe_id equals to
'CSS_PIPE_ID_COPY' or not. It should be removed.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 6bdd19e..929ed80 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -910,8 +910,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) {
/* For online video or SDV video pipe. */
if (css_pipe_id == CSS_PIPE_ID_VIDEO ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP) {
+   css_pipe_id == CSS_PIPE_ID_COPY) {
if (buf_type == CSS_BUFFER_TYPE_OUTPUT_FRAME)
return >video_out_video_capture;
return >video_out_preview;
@@ -919,8 +918,7 @@ static struct atomisp_video_pipe *__atomisp_get_pipe(
} else if (asd->run_mode->val == ATOMISP_RUN_MODE_PREVIEW) {
/* For online preview or ZSL preview pipe. */
if (css_pipe_id == CSS_PIPE_ID_PREVIEW ||
-   css_pipe_id == CSS_PIPE_ID_COPY ||
-   css_pipe_id == CSS_PIPE_ID_YUVPP)
+   css_pipe_id == CSS_PIPE_ID_COPY)
return >video_out_preview;
}
/* For capture pipe. */
-- 
1.9.1



[PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread Daeseok Youn
If v4l2_subdev_call() gets the global frame interval values,
it returned 0 and it could be checked whether numerator is zero or not.

If the numerator is not zero, the fps could be calculated in this function.
If not, it just returns 0.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 8bdb224..6bdd19e 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -153,20 +153,18 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
video_device *dev)
 
 static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
 {
-   struct v4l2_subdev_frame_interval frame_interval;
+   struct v4l2_subdev_frame_interval fi;
struct atomisp_device *isp = asd->isp;
-   unsigned short fps;
 
-   if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-   video, g_frame_interval, _interval)) {
-   fps = 0;
-   } else {
-   if (frame_interval.interval.numerator)
-   fps = frame_interval.interval.denominator /
-   frame_interval.interval.numerator;
-   else
-   fps = 0;
-   }
+   unsigned short fps = 0;
+   int ret;
+
+   ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+  video, g_frame_interval, );
+
+   if (!ret && fi.interval.numerator)
+   fps = fi.interval.denominator / fi.interval.numerator;
+
return fps;
 }
 
-- 
1.9.1



[PATCH 2/4] staging: atomisp: simplify if statement in atomisp_get_sensor_fps()

2017-03-20 Thread Daeseok Youn
If v4l2_subdev_call() gets the global frame interval values,
it returned 0 and it could be checked whether numerator is zero or not.

If the numerator is not zero, the fps could be calculated in this function.
If not, it just returns 0.

Signed-off-by: Daeseok Youn 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 8bdb224..6bdd19e 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -153,20 +153,18 @@ struct atomisp_acc_pipe *atomisp_to_acc_pipe(struct 
video_device *dev)
 
 static unsigned short atomisp_get_sensor_fps(struct atomisp_sub_device *asd)
 {
-   struct v4l2_subdev_frame_interval frame_interval;
+   struct v4l2_subdev_frame_interval fi;
struct atomisp_device *isp = asd->isp;
-   unsigned short fps;
 
-   if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-   video, g_frame_interval, _interval)) {
-   fps = 0;
-   } else {
-   if (frame_interval.interval.numerator)
-   fps = frame_interval.interval.denominator /
-   frame_interval.interval.numerator;
-   else
-   fps = 0;
-   }
+   unsigned short fps = 0;
+   int ret;
+
+   ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
+  video, g_frame_interval, );
+
+   if (!ret && fi.interval.numerator)
+   fps = fi.interval.denominator / fi.interval.numerator;
+
return fps;
 }
 
-- 
1.9.1



[PATCH 4/4] staging: atomisp: remove redudant condition in if-statement

2017-03-20 Thread Daeseok Youn
The V4L2_FIELD_ANY is zero, so the (!field) is same meaning
with (field == V4L2_FIELD_ANY) in if-statement.

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

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 929ed80..2437162 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -5084,7 +5084,7 @@ int atomisp_try_fmt(struct video_device *vdev, struct 
v4l2_format *f,
 
depth = get_pixel_depth(pixelformat);
 
-   if (!field || field == V4L2_FIELD_ANY)
+   if (field == V4L2_FIELD_ANY)
field = V4L2_FIELD_NONE;
else if (field != V4L2_FIELD_NONE) {
dev_err(isp->dev, "Wrong output field\n");
-- 
1.9.1



[PATCH 4/4] staging: atomisp: remove redudant condition in if-statement

2017-03-20 Thread Daeseok Youn
The V4L2_FIELD_ANY is zero, so the (!field) is same meaning
with (field == V4L2_FIELD_ANY) in if-statement.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 929ed80..2437162 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -5084,7 +5084,7 @@ int atomisp_try_fmt(struct video_device *vdev, struct 
v4l2_format *f,
 
depth = get_pixel_depth(pixelformat);
 
-   if (!field || field == V4L2_FIELD_ANY)
+   if (field == V4L2_FIELD_ANY)
field = V4L2_FIELD_NONE;
else if (field != V4L2_FIELD_NONE) {
dev_err(isp->dev, "Wrong output field\n");
-- 
1.9.1



[PATCH 1/4] staging: atomisp: remove else statement after return

2017-03-20 Thread Daeseok Youn
It doesn't need to have else statement after return.

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

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index d97a8df..8bdb224 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -2958,11 +2958,11 @@ int atomisp_get_metadata(struct atomisp_sub_device 
*asd, int flag,
dev_err(isp->dev, "copy to user failed: copied %d bytes\n",
ret);
return -EFAULT;
-   } else {
-   list_del_init(_buf->list);
-   list_add_tail(_buf->list, >metadata[md_type]);
}
 
+   list_del_init(_buf->list);
+   list_add_tail(_buf->list, >metadata[md_type]);
+
dev_dbg(isp->dev, "%s: HAL de-queued metadata type %d with exp_id %d\n",
__func__, md_type, md->exp_id);
return 0;
-- 
1.9.1



[PATCH 1/4] staging: atomisp: remove else statement after return

2017-03-20 Thread Daeseok Youn
It doesn't need to have else statement after return.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index d97a8df..8bdb224 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -2958,11 +2958,11 @@ int atomisp_get_metadata(struct atomisp_sub_device 
*asd, int flag,
dev_err(isp->dev, "copy to user failed: copied %d bytes\n",
ret);
return -EFAULT;
-   } else {
-   list_del_init(_buf->list);
-   list_add_tail(_buf->list, >metadata[md_type]);
}
 
+   list_del_init(_buf->list);
+   list_add_tail(_buf->list, >metadata[md_type]);
+
dev_dbg(isp->dev, "%s: HAL de-queued metadata type %d with exp_id %d\n",
__func__, md_type, md->exp_id);
return 0;
-- 
1.9.1



[PATCH 3/4] staging: atomisp: remove useless #ifdef ISP2401 on top of atomisp_cmd.c

2017-03-15 Thread Daeseok Youn
There is no reason to have "#ifdef ISP2401" condition
on top of atomisp_cmd.c file

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

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 6160119..82e7382 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -1,6 +1,3 @@
-#ifdef ISP2401
-
-#endif
 /*
  * Support for Medifield PNW Camera Imaging ISP subsystem.
  *
-- 
1.9.1



[PATCH 3/4] staging: atomisp: remove useless #ifdef ISP2401 on top of atomisp_cmd.c

2017-03-15 Thread Daeseok Youn
There is no reason to have "#ifdef ISP2401" condition
on top of atomisp_cmd.c file

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 6160119..82e7382 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -1,6 +1,3 @@
-#ifdef ISP2401
-
-#endif
 /*
  * Support for Medifield PNW Camera Imaging ISP subsystem.
  *
-- 
1.9.1



[PATCH 4/4] staging: atomisp: fix "alignment should match open parenthesis"

2017-03-15 Thread Daeseok Youn
Fix checkpatch.pl issues in atomisp_cmd.c
 : "CHECK: Alignment should match open parenthesis"

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 179 +++--
 1 file changed, 90 insertions(+), 89 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 82e7382..d97a8df 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -158,7 +158,7 @@ static unsigned short atomisp_get_sensor_fps(struct 
atomisp_sub_device *asd)
unsigned short fps;
 
if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-   video, g_frame_interval, _interval)) {
+   video, g_frame_interval, _interval)) {
fps = 0;
} else {
if (frame_interval.interval.numerator)
@@ -481,7 +481,7 @@ static void atomisp_3a_stats_ready_event(struct 
atomisp_sub_device *asd, uint8_t
 }
 
 static void atomisp_metadata_ready_event(struct atomisp_sub_device *asd,
-   enum atomisp_metadata_type 
md_type)
+enum atomisp_metadata_type md_type)
 {
struct v4l2_event event = {0};
 
@@ -622,14 +622,14 @@ irqreturn_t atomisp_isr(int irq, void *dev)
}
if (irq_infos & CSS_IRQ_INFO_EVENTS_READY)
atomic_set(>sequence,
-   atomic_read(>sequence_temp));
+  atomic_read(>sequence_temp));
}
 
if (irq_infos & CSS_IRQ_INFO_CSS_RECEIVER_SOF)
irq_infos &= ~CSS_IRQ_INFO_CSS_RECEIVER_SOF;
 
if ((irq_infos & CSS_IRQ_INFO_INPUT_SYSTEM_ERROR) ||
-   (irq_infos & CSS_IRQ_INFO_IF_ERROR)) {
+   (irq_infos & CSS_IRQ_INFO_IF_ERROR)) {
/* handle mipi receiver error */
u32 rx_infos;
enum ia_css_csi2_port port;
@@ -684,7 +684,7 @@ void atomisp_clear_css_buffer_counters(struct 
atomisp_sub_device *asd)
memset(asd->s3a_bufs_in_css, 0, sizeof(asd->s3a_bufs_in_css));
for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++)
memset(asd->metadata_bufs_in_css[i], 0,
-   sizeof(asd->metadata_bufs_in_css[i]));
+  sizeof(asd->metadata_bufs_in_css[i]));
asd->dis_bufs_in_css = 0;
asd->video_out_capture.buffers_in_css = 0;
asd->video_out_vf.buffers_in_css = 0;
@@ -804,7 +804,7 @@ void atomisp_flush_params_queue(struct atomisp_video_pipe 
*pipe)
 
while (!list_empty(>per_frame_params)) {
param = list_entry(pipe->per_frame_params.next,
-   struct atomisp_css_params_with_list, list);
+  struct atomisp_css_params_with_list, list);
list_del(>list);
atomisp_free_css_parameters(>params);
atomisp_kernel_free(param);
@@ -983,7 +983,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int 
error,
memset(, 0, sizeof(struct atomisp_css_buffer));
buffer.css_buffer.type = buf_type;
err = atomisp_css_dequeue_buffer(asd, stream_id, css_pipe_id,
-   buf_type, );
+buf_type, );
if (err) {
dev_err(isp->dev,
"atomisp_css_dequeue_buffer failed: 0x%x\n", err);
@@ -1000,12 +1000,12 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, 
int error,
switch (buf_type) {
case CSS_BUFFER_TYPE_3A_STATISTICS:
list_for_each_entry_safe(s3a_buf, _s3a_buf_tmp,
-   >s3a_stats_in_css, list) {
+>s3a_stats_in_css, list) {
if (s3a_buf->s3a_data ==
buffer.css_buffer.data.stats_3a) {
list_del_init(_buf->list);
list_add_tail(_buf->list,
-   >s3a_stats_ready);
+ >s3a_stats_ready);
break;
}
}
@@ -1021,12 +1021,12 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, 
int error,
 
md_type = atomisp_get_metadata_type(asd, css_pipe_id);
list_for_each_entry_safe(md_buf, _md_buf_tmp,
-   >metadata_in_css[md_type], list) {
+>metadata_in_css[md_type], list) {
if (md_buf-&g

[PATCH 4/4] staging: atomisp: fix "alignment should match open parenthesis"

2017-03-15 Thread Daeseok Youn
Fix checkpatch.pl issues in atomisp_cmd.c
 : "CHECK: Alignment should match open parenthesis"

Signed-off-by: Daeseok Youn 
---
 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 179 +++--
 1 file changed, 90 insertions(+), 89 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 82e7382..d97a8df 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -158,7 +158,7 @@ static unsigned short atomisp_get_sensor_fps(struct 
atomisp_sub_device *asd)
unsigned short fps;
 
if (v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
-   video, g_frame_interval, _interval)) {
+   video, g_frame_interval, _interval)) {
fps = 0;
} else {
if (frame_interval.interval.numerator)
@@ -481,7 +481,7 @@ static void atomisp_3a_stats_ready_event(struct 
atomisp_sub_device *asd, uint8_t
 }
 
 static void atomisp_metadata_ready_event(struct atomisp_sub_device *asd,
-   enum atomisp_metadata_type 
md_type)
+enum atomisp_metadata_type md_type)
 {
struct v4l2_event event = {0};
 
@@ -622,14 +622,14 @@ irqreturn_t atomisp_isr(int irq, void *dev)
}
if (irq_infos & CSS_IRQ_INFO_EVENTS_READY)
atomic_set(>sequence,
-   atomic_read(>sequence_temp));
+  atomic_read(>sequence_temp));
}
 
if (irq_infos & CSS_IRQ_INFO_CSS_RECEIVER_SOF)
irq_infos &= ~CSS_IRQ_INFO_CSS_RECEIVER_SOF;
 
if ((irq_infos & CSS_IRQ_INFO_INPUT_SYSTEM_ERROR) ||
-   (irq_infos & CSS_IRQ_INFO_IF_ERROR)) {
+   (irq_infos & CSS_IRQ_INFO_IF_ERROR)) {
/* handle mipi receiver error */
u32 rx_infos;
enum ia_css_csi2_port port;
@@ -684,7 +684,7 @@ void atomisp_clear_css_buffer_counters(struct 
atomisp_sub_device *asd)
memset(asd->s3a_bufs_in_css, 0, sizeof(asd->s3a_bufs_in_css));
for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++)
memset(asd->metadata_bufs_in_css[i], 0,
-   sizeof(asd->metadata_bufs_in_css[i]));
+  sizeof(asd->metadata_bufs_in_css[i]));
asd->dis_bufs_in_css = 0;
asd->video_out_capture.buffers_in_css = 0;
asd->video_out_vf.buffers_in_css = 0;
@@ -804,7 +804,7 @@ void atomisp_flush_params_queue(struct atomisp_video_pipe 
*pipe)
 
while (!list_empty(>per_frame_params)) {
param = list_entry(pipe->per_frame_params.next,
-   struct atomisp_css_params_with_list, list);
+  struct atomisp_css_params_with_list, list);
list_del(>list);
atomisp_free_css_parameters(>params);
atomisp_kernel_free(param);
@@ -983,7 +983,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int 
error,
memset(, 0, sizeof(struct atomisp_css_buffer));
buffer.css_buffer.type = buf_type;
err = atomisp_css_dequeue_buffer(asd, stream_id, css_pipe_id,
-   buf_type, );
+buf_type, );
if (err) {
dev_err(isp->dev,
"atomisp_css_dequeue_buffer failed: 0x%x\n", err);
@@ -1000,12 +1000,12 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, 
int error,
switch (buf_type) {
case CSS_BUFFER_TYPE_3A_STATISTICS:
list_for_each_entry_safe(s3a_buf, _s3a_buf_tmp,
-   >s3a_stats_in_css, list) {
+>s3a_stats_in_css, list) {
if (s3a_buf->s3a_data ==
buffer.css_buffer.data.stats_3a) {
list_del_init(_buf->list);
list_add_tail(_buf->list,
-   >s3a_stats_ready);
+ >s3a_stats_ready);
break;
}
}
@@ -1021,12 +1021,12 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, 
int error,
 
md_type = atomisp_get_metadata_type(asd, css_pipe_id);
list_for_each_entry_safe(md_buf, _md_buf_tmp,
-   >metadata_in_css[md_type], list) {
+>metadata_in_css[md_type], list) {
if (md_buf->metadata ==
buffer.css_buffer.d

[PATCH 2/4] staging: atomisp: fix inconsistent indenting

2017-03-15 Thread Daeseok Youn
Fix warnings from the smatch tool

atomisp_cmd.c:5698
   atomisp_set_fmt_to_snr() warn: inconsistent indenting
atomisp_cmd.c:5714
   atomisp_set_fmt_to_snr() warn: inconsistent indenting

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

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 9c3ba11..6160119 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -5693,7 +5693,7 @@ static int atomisp_set_fmt_to_snr(struct video_device 
*vdev,
/* Disable dvs if resolution can't be supported by sensor */
if (asd->params.video_dis_en &&
source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO) {
-   vformat.which = V4L2_SUBDEV_FORMAT_TRY;
+   vformat.which = V4L2_SUBDEV_FORMAT_TRY;
ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
pad, set_fmt, _cfg, );
if (ret)
@@ -5710,7 +5710,7 @@ static int atomisp_set_fmt_to_snr(struct video_device 
*vdev,
}
dev_dbg(isp->dev, "sensor width: %d, height: %d\n",
ffmt->width, ffmt->height);
-vformat.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+   vformat.which = V4L2_SUBDEV_FORMAT_ACTIVE;
ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, pad,
   set_fmt, NULL, );
if (ret)
-- 
1.9.1



[PATCH 2/4] staging: atomisp: fix inconsistent indenting

2017-03-15 Thread Daeseok Youn
Fix warnings from the smatch tool

atomisp_cmd.c:5698
   atomisp_set_fmt_to_snr() warn: inconsistent indenting
atomisp_cmd.c:5714
   atomisp_set_fmt_to_snr() warn: inconsistent indenting

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 9c3ba11..6160119 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -5693,7 +5693,7 @@ static int atomisp_set_fmt_to_snr(struct video_device 
*vdev,
/* Disable dvs if resolution can't be supported by sensor */
if (asd->params.video_dis_en &&
source_pad == ATOMISP_SUBDEV_PAD_SOURCE_VIDEO) {
-   vformat.which = V4L2_SUBDEV_FORMAT_TRY;
+   vformat.which = V4L2_SUBDEV_FORMAT_TRY;
ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
pad, set_fmt, _cfg, );
if (ret)
@@ -5710,7 +5710,7 @@ static int atomisp_set_fmt_to_snr(struct video_device 
*vdev,
}
dev_dbg(isp->dev, "sensor width: %d, height: %d\n",
ffmt->width, ffmt->height);
-vformat.which = V4L2_SUBDEV_FORMAT_ACTIVE;
+   vformat.which = V4L2_SUBDEV_FORMAT_ACTIVE;
ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, pad,
   set_fmt, NULL, );
if (ret)
-- 
1.9.1



[PATCH 1/4] staging: atomisp: fix unsigned int comparison with less than zero

2017-03-14 Thread Daeseok Youn
Fix warnings from the smatch tool

atomisp_cmd.c:2649
  atomisp_set_array_res() warn:
  unsigned 'config->width' is never less than zero.

atomisp_cmd.c:2650
  atomisp_set_array_res() warn:
  unsigned 'config->height' is never less than zero.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 1ee99d0..9c3ba11 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -2646,8 +2646,7 @@ int atomisp_set_array_res(struct atomisp_sub_device *asd,
 struct atomisp_resolution  *config)
 {
dev_dbg(asd->isp->dev, ">%s start\n", __func__);
-   if (config == NULL || config->width < 0
-   || config->height < 0) {
+   if (!config) {
dev_err(asd->isp->dev, "Set sensor array size is not valid\n");
return -EINVAL;
}
-- 
1.9.1



[PATCH 1/4] staging: atomisp: fix unsigned int comparison with less than zero

2017-03-14 Thread Daeseok Youn
Fix warnings from the smatch tool

atomisp_cmd.c:2649
  atomisp_set_array_res() warn:
  unsigned 'config->width' is never less than zero.

atomisp_cmd.c:2650
  atomisp_set_array_res() warn:
  unsigned 'config->height' is never less than zero.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index 1ee99d0..9c3ba11 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -2646,8 +2646,7 @@ int atomisp_set_array_res(struct atomisp_sub_device *asd,
 struct atomisp_resolution  *config)
 {
dev_dbg(asd->isp->dev, ">%s start\n", __func__);
-   if (config == NULL || config->width < 0
-   || config->height < 0) {
+   if (!config) {
dev_err(asd->isp->dev, "Set sensor array size is not valid\n");
return -EINVAL;
}
-- 
1.9.1



[PATCH 2/2 V2] staging: dgnc: remove useless switch-case statements

2017-03-13 Thread Daeseok Youn
The dgnc_tty_send_break() has a switch-case condition for msec.
It is no use except case -1.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: The two patches in previous series are merged into one patch.

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

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index dc76e9f..854bd1d 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1790,16 +1790,8 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return -EIO;
 
-   switch (msec) {
-   case -1:
+   if (msec < 0)
msec = 0x;
-   break;
-   case 0:
-   msec = 0;
-   break;
-   default:
-   break;
-   }
 
spin_lock_irqsave(>ch_lock, flags);
 
-- 
1.9.1



[PATCH 2/2 V2] staging: dgnc: remove useless switch-case statements

2017-03-13 Thread Daeseok Youn
The dgnc_tty_send_break() has a switch-case condition for msec.
It is no use except case -1.

Signed-off-by: Daeseok Youn 
---
V2: The two patches in previous series are merged into one patch.

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

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index dc76e9f..854bd1d 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1790,16 +1790,8 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return -EIO;
 
-   switch (msec) {
-   case -1:
+   if (msec < 0)
msec = 0x;
-   break;
-   case 0:
-   msec = 0;
-   break;
-   default:
-   break;
-   }
 
spin_lock_irqsave(>ch_lock, flags);
 
-- 
1.9.1



[PATCH 1/2 V2] staging: dgnc: ch->ch_bd is already assigned to bd variable

2017-03-13 Thread Daeseok Youn
The bd variables in functions are already assigned from
ch->ch_bd but it is not used in those functions except checking NULL.

The ch->ch_bd could be replaced with bd variable.

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
V2: Patches in previous series are splited but it could be merged into one.
There are lines to replace ch->ch_bd with bd variable.

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

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 1861bd5..dc76e9f 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1756,7 +1756,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty,
if (clear & TIOCM_DTR)
ch->ch_mostat &= ~(UART_MCR_DTR);
 
-   ch->ch_bd->bd_ops->assert_modem_signals(ch);
+   bd->bd_ops->assert_modem_signals(ch);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -1803,7 +1803,7 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
 
spin_lock_irqsave(>ch_lock, flags);
 
-   ch->ch_bd->bd_ops->send_break(ch, msec);
+   bd->bd_ops->send_break(ch, msec);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -2095,7 +2095,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty,
if (ch->ch_digi.digi_offlen > DIGI_PLEN)
ch->ch_digi.digi_offlen = DIGI_PLEN;
 
-   ch->ch_bd->bd_ops->param(tty);
+   bd->bd_ops->param(tty);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -2136,7 +2136,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty,
ch->ch_startc = tty->termios.c_cc[VSTART];
ch->ch_stopc  = tty->termios.c_cc[VSTOP];
 
-   ch->ch_bd->bd_ops->param(tty);
+   bd->bd_ops->param(tty);
dgnc_carrier(ch);
 
spin_unlock_irqrestore(>ch_lock, flags);
-- 
1.9.1



[PATCH 1/2 V2] staging: dgnc: ch->ch_bd is already assigned to bd variable

2017-03-13 Thread Daeseok Youn
The bd variables in functions are already assigned from
ch->ch_bd but it is not used in those functions except checking NULL.

The ch->ch_bd could be replaced with bd variable.

Signed-off-by: Daeseok Youn 
---
V2: Patches in previous series are splited but it could be merged into one.
There are lines to replace ch->ch_bd with bd variable.

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

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 1861bd5..dc76e9f 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1756,7 +1756,7 @@ static int dgnc_tty_tiocmset(struct tty_struct *tty,
if (clear & TIOCM_DTR)
ch->ch_mostat &= ~(UART_MCR_DTR);
 
-   ch->ch_bd->bd_ops->assert_modem_signals(ch);
+   bd->bd_ops->assert_modem_signals(ch);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -1803,7 +1803,7 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
 
spin_lock_irqsave(>ch_lock, flags);
 
-   ch->ch_bd->bd_ops->send_break(ch, msec);
+   bd->bd_ops->send_break(ch, msec);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -2095,7 +2095,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty,
if (ch->ch_digi.digi_offlen > DIGI_PLEN)
ch->ch_digi.digi_offlen = DIGI_PLEN;
 
-   ch->ch_bd->bd_ops->param(tty);
+   bd->bd_ops->param(tty);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
@@ -2136,7 +2136,7 @@ static void dgnc_tty_set_termios(struct tty_struct *tty,
ch->ch_startc = tty->termios.c_cc[VSTART];
ch->ch_stopc  = tty->termios.c_cc[VSTOP];
 
-   ch->ch_bd->bd_ops->param(tty);
+   bd->bd_ops->param(tty);
dgnc_carrier(ch);
 
spin_unlock_irqrestore(>ch_lock, flags);
-- 
1.9.1



Re: [PATCH 3/3] staging: dngc: ch->ch_bd is already assigned to bd variable

2017-03-13 Thread DaeSeok Youn
2017-03-14 7:26 GMT+09:00 Greg KH <gre...@linuxfoundation.org>:
> On Sun, Mar 12, 2017 at 11:47:28PM +0900, Daeseok Youn wrote:
>> The bd variable in dgnc_tty_digiseta() is assigned with
>> ch->ch_bd but it is not used in this function except checking NULL.
>> The ch->ch_bd could be replaced with bd variable in dgnc_tty_digiseta()
>>
>> Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
>> ---
>>  drivers/staging/dgnc/dgnc_tty.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Please merge this with your first patch in the series and resend them.
Hi Greg,

Ok. I will merge this with my first patch and send them.

Thanks,
Regards,
Daeseok Youn.

>
> thanks,
>
> greg k-h


Re: [PATCH 3/3] staging: dngc: ch->ch_bd is already assigned to bd variable

2017-03-13 Thread DaeSeok Youn
2017-03-14 7:26 GMT+09:00 Greg KH :
> On Sun, Mar 12, 2017 at 11:47:28PM +0900, Daeseok Youn wrote:
>> The bd variable in dgnc_tty_digiseta() is assigned with
>> ch->ch_bd but it is not used in this function except checking NULL.
>> The ch->ch_bd could be replaced with bd variable in dgnc_tty_digiseta()
>>
>> Signed-off-by: Daeseok Youn 
>> ---
>>  drivers/staging/dgnc/dgnc_tty.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Please merge this with your first patch in the series and resend them.
Hi Greg,

Ok. I will merge this with my first patch and send them.

Thanks,
Regards,
Daeseok Youn.

>
> thanks,
>
> greg k-h


Re: [PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread DaeSeok Youn
2017-03-14 2:54 GMT+09:00 Alan Cox <a...@linux.intel.com>:
>
> On Mon, 2017-03-13 at 19:54 +0900, Daeseok Youn wrote:
> > If the atomisp_kernel_zalloc() has "true" as a second parameter, it
> > tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
> > But using kzalloc is rather than kmalloc followed by memset with 0.
> > (vzalloc is for same reason with kzalloc)
>
> This is true but please don't apply this. There are about five other
> layers of indirection for memory allocators that want removing first so
> that the driver just uses the correct kmalloc/kzalloc/kv* functions in
> the right places.
right. kvmalloc/kvzalloc would be used after preparing those
interfaces in staging tree.
I will try to change all the atomisp_kernel_m{z}alloc() callers to
correct functions to allocate memory.

Thanks.
Regards,
Jake.

>
> Alan
>


Re: [PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread DaeSeok Youn
2017-03-14 2:54 GMT+09:00 Alan Cox :
>
> On Mon, 2017-03-13 at 19:54 +0900, Daeseok Youn wrote:
> > If the atomisp_kernel_zalloc() has "true" as a second parameter, it
> > tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
> > But using kzalloc is rather than kmalloc followed by memset with 0.
> > (vzalloc is for same reason with kzalloc)
>
> This is true but please don't apply this. There are about five other
> layers of indirection for memory allocators that want removing first so
> that the driver just uses the correct kmalloc/kzalloc/kv* functions in
> the right places.
right. kvmalloc/kvzalloc would be used after preparing those
interfaces in staging tree.
I will try to change all the atomisp_kernel_m{z}alloc() callers to
correct functions to allocate memory.

Thanks.
Regards,
Jake.

>
> Alan
>


Re: [PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread DaeSeok Youn
2017-03-13 23:07 GMT+09:00 DaeSeok Youn <daeseok.y...@gmail.com>:
> 2017-03-13 20:51 GMT+09:00 Dan Carpenter <dan.carpen...@oracle.com>:
>> On Mon, Mar 13, 2017 at 07:54:21PM +0900, Daeseok Youn wrote:
>>> If the atomisp_kernel_zalloc() has "true" as a second parameter, it
>>> tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
>>> But using kzalloc is rather than kmalloc followed by memset with 0.
>>> (vzalloc is for same reason with kzalloc)
>>>
>>> And also atomisp_kernel_malloc() can be used with
>>> atomisp_kernel_zalloc(, false);
>>>
>>
>> We should just change all the callers to kvmalloc() and kvzmalloc().
> ok. I will try to change all the callers to kvmalloc() and kvzalloc().

The kvmalloc() and kvzalloc() are not ready to use in staging-testing
branch on staging tree.
If the kvmalloc and kvzalloc are available to use, I will replace
atomisp_kernel_malloc() and atomisp_kernel_zalloc() with kvmalloc()
and kvzalloc().

Thanks.
Regards,
Daeseok Youn.


>
> Thanks.
> Regards,
> Daeseok Youn
>>
>> regards,
>> dan carpenter
>>


Re: [PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread DaeSeok Youn
2017-03-13 23:07 GMT+09:00 DaeSeok Youn :
> 2017-03-13 20:51 GMT+09:00 Dan Carpenter :
>> On Mon, Mar 13, 2017 at 07:54:21PM +0900, Daeseok Youn wrote:
>>> If the atomisp_kernel_zalloc() has "true" as a second parameter, it
>>> tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
>>> But using kzalloc is rather than kmalloc followed by memset with 0.
>>> (vzalloc is for same reason with kzalloc)
>>>
>>> And also atomisp_kernel_malloc() can be used with
>>> atomisp_kernel_zalloc(, false);
>>>
>>
>> We should just change all the callers to kvmalloc() and kvzmalloc().
> ok. I will try to change all the callers to kvmalloc() and kvzalloc().

The kvmalloc() and kvzalloc() are not ready to use in staging-testing
branch on staging tree.
If the kvmalloc and kvzalloc are available to use, I will replace
atomisp_kernel_malloc() and atomisp_kernel_zalloc() with kvmalloc()
and kvzalloc().

Thanks.
Regards,
Daeseok Youn.


>
> Thanks.
> Regards,
> Daeseok Youn
>>
>> regards,
>> dan carpenter
>>


Re: [PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread DaeSeok Youn
2017-03-13 20:51 GMT+09:00 Dan Carpenter <dan.carpen...@oracle.com>:
> On Mon, Mar 13, 2017 at 07:54:21PM +0900, Daeseok Youn wrote:
>> If the atomisp_kernel_zalloc() has "true" as a second parameter, it
>> tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
>> But using kzalloc is rather than kmalloc followed by memset with 0.
>> (vzalloc is for same reason with kzalloc)
>>
>> And also atomisp_kernel_malloc() can be used with
>> atomisp_kernel_zalloc(, false);
>>
>
> We should just change all the callers to kvmalloc() and kvzmalloc().
ok. I will try to change all the callers to kvmalloc() and kvzalloc().

Thanks.
Regards,
Daeseok Youn
>
> regards,
> dan carpenter
>


Re: [PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread DaeSeok Youn
2017-03-13 20:51 GMT+09:00 Dan Carpenter :
> On Mon, Mar 13, 2017 at 07:54:21PM +0900, Daeseok Youn wrote:
>> If the atomisp_kernel_zalloc() has "true" as a second parameter, it
>> tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
>> But using kzalloc is rather than kmalloc followed by memset with 0.
>> (vzalloc is for same reason with kzalloc)
>>
>> And also atomisp_kernel_malloc() can be used with
>> atomisp_kernel_zalloc(, false);
>>
>
> We should just change all the callers to kvmalloc() and kvzmalloc().
ok. I will try to change all the callers to kvmalloc() and kvzalloc().

Thanks.
Regards,
Daeseok Youn
>
> regards,
> dan carpenter
>


[PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread Daeseok Youn
If the atomisp_kernel_zalloc() has "true" as a second parameter, it
tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
But using kzalloc is rather than kmalloc followed by memset with 0.
(vzalloc is for same reason with kzalloc)

And also atomisp_kernel_malloc() can be used with
atomisp_kernel_zalloc(, false);

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
I think kvmalloc() or kvzalloc() can be used to allocate memory if there is
no reason to use vmalloc() when the requested bytes is over PAGE_SIZE.

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 25 --
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index d9a5c24..44b2244 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -86,32 +86,35 @@
 };
 
 /*
- * atomisp_kernel_malloc: chooses whether kmalloc() or vmalloc() is preferable.
+ * atomisp_kernel_malloc:
+ * allocating memory from atomisp_kernel_zalloc() without zeroing memory.
  *
  * It is also a wrap functions to pass into css framework.
  */
 void *atomisp_kernel_malloc(size_t bytes)
 {
-   /* vmalloc() is preferable if allocating more than 1 page */
-   if (bytes > PAGE_SIZE)
-   return vmalloc(bytes);
-
-   return kmalloc(bytes, GFP_KERNEL);
+   return atomisp_kernel_zalloc(bytes, false);
 }
 
 /*
- * atomisp_kernel_zalloc: chooses whether set 0 to the allocated memory.
+ * atomisp_kernel_zalloc: chooses whether set 0 to the allocated memory
+ * with k{z,m}alloc or v{z,m}alloc
  *
  * It is also a wrap functions to pass into css framework.
  */
 void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
 {
-   void *ptr = atomisp_kernel_malloc(bytes);
+   /* vmalloc() is preferable if allocating more than 1 page */
+   if (bytes > PAGE_SIZE) {
+   if (zero_mem)
+   return vzalloc(bytes);
+   return vmalloc(bytes);
+   }
 
-   if (ptr && zero_mem)
-   memset(ptr, 0, bytes);
+   if (zero_mem)
+   return kzalloc(bytes, GFP_KERNEL);
 
-   return ptr;
+   return kmalloc(bytes, GFP_KERNEL);
 }
 
 /*
-- 
1.9.1



[PATCH] staging: atomisp: use k{v}zalloc instead of k{v}alloc and memset

2017-03-13 Thread Daeseok Youn
If the atomisp_kernel_zalloc() has "true" as a second parameter, it
tries to allocate zeroing memory from kmalloc(vmalloc) and memset.
But using kzalloc is rather than kmalloc followed by memset with 0.
(vzalloc is for same reason with kzalloc)

And also atomisp_kernel_malloc() can be used with
atomisp_kernel_zalloc(, false);

Signed-off-by: Daeseok Youn 
---
I think kvmalloc() or kvzalloc() can be used to allocate memory if there is
no reason to use vmalloc() when the requested bytes is over PAGE_SIZE.

 .../media/atomisp/pci/atomisp2/atomisp_cmd.c   | 25 --
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c 
b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
index d9a5c24..44b2244 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c
@@ -86,32 +86,35 @@
 };
 
 /*
- * atomisp_kernel_malloc: chooses whether kmalloc() or vmalloc() is preferable.
+ * atomisp_kernel_malloc:
+ * allocating memory from atomisp_kernel_zalloc() without zeroing memory.
  *
  * It is also a wrap functions to pass into css framework.
  */
 void *atomisp_kernel_malloc(size_t bytes)
 {
-   /* vmalloc() is preferable if allocating more than 1 page */
-   if (bytes > PAGE_SIZE)
-   return vmalloc(bytes);
-
-   return kmalloc(bytes, GFP_KERNEL);
+   return atomisp_kernel_zalloc(bytes, false);
 }
 
 /*
- * atomisp_kernel_zalloc: chooses whether set 0 to the allocated memory.
+ * atomisp_kernel_zalloc: chooses whether set 0 to the allocated memory
+ * with k{z,m}alloc or v{z,m}alloc
  *
  * It is also a wrap functions to pass into css framework.
  */
 void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem)
 {
-   void *ptr = atomisp_kernel_malloc(bytes);
+   /* vmalloc() is preferable if allocating more than 1 page */
+   if (bytes > PAGE_SIZE) {
+   if (zero_mem)
+   return vzalloc(bytes);
+   return vmalloc(bytes);
+   }
 
-   if (ptr && zero_mem)
-   memset(ptr, 0, bytes);
+   if (zero_mem)
+   return kzalloc(bytes, GFP_KERNEL);
 
-   return ptr;
+   return kmalloc(bytes, GFP_KERNEL);
 }
 
 /*
-- 
1.9.1



[PATCH 3/3] staging: dngc: ch->ch_bd is already assigned to bd variable

2017-03-12 Thread Daeseok Youn
The bd variable in dgnc_tty_digiseta() is assigned with
ch->ch_bd but it is not used in this function except checking NULL.
The ch->ch_bd could be replaced with bd variable in dgnc_tty_digiseta()

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

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 7133d2c..b075350 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -2081,7 +2081,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty,
if (ch->ch_digi.digi_offlen > DIGI_PLEN)
ch->ch_digi.digi_offlen = DIGI_PLEN;
 
-   ch->ch_bd->bd_ops->param(tty);
+   bd->bd_ops->param(tty);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
-- 
2.7.4



[PATCH 3/3] staging: dngc: ch->ch_bd is already assigned to bd variable

2017-03-12 Thread Daeseok Youn
The bd variable in dgnc_tty_digiseta() is assigned with
ch->ch_bd but it is not used in this function except checking NULL.
The ch->ch_bd could be replaced with bd variable in dgnc_tty_digiseta()

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 7133d2c..b075350 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -2081,7 +2081,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty,
if (ch->ch_digi.digi_offlen > DIGI_PLEN)
ch->ch_digi.digi_offlen = DIGI_PLEN;
 
-   ch->ch_bd->bd_ops->param(tty);
+   bd->bd_ops->param(tty);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
-- 
2.7.4



[PATCH 2/3] staging: dgnc: remove useless switch-case statements

2017-03-12 Thread Daeseok Youn
The dgnc_tty_send_break() has a switch-case condition for msec.
It is no use except case -1.

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

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index c563ee3..7133d2c 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1786,16 +1786,8 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return ret;
 
-   switch (msec) {
-   case -1:
+   if (msec < 0)
msec = 0x;
-   break;
-   case 0:
-   msec = 0;
-   break;
-   default:
-   break;
-   }
 
spin_lock_irqsave(>ch_lock, flags);
 
-- 
2.7.4



[PATCH 2/3] staging: dgnc: remove useless switch-case statements

2017-03-12 Thread Daeseok Youn
The dgnc_tty_send_break() has a switch-case condition for msec.
It is no use except case -1.

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_tty.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index c563ee3..7133d2c 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1786,16 +1786,8 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return ret;
 
-   switch (msec) {
-   case -1:
+   if (msec < 0)
msec = 0x;
-   break;
-   case 0:
-   msec = 0;
-   break;
-   default:
-   break;
-   }
 
spin_lock_irqsave(>ch_lock, flags);
 
-- 
2.7.4



[PATCH 1/3] staging: dgnc: ch->ch_bd is already assigned to bd variable

2017-03-12 Thread Daeseok Youn
The bd variable in dgnc_tty_send_break() is assigned with
ch->ch_bd but it is not used in this function except checking NULL.
The ch->ch_bd could be replaced with bd variable in dgnc_tty_send_break()

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

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index cde00e3..c563ee3 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1799,7 +1799,7 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
 
spin_lock_irqsave(>ch_lock, flags);
 
-   ch->ch_bd->bd_ops->send_break(ch, msec);
+   bd->bd_ops->send_break(ch, msec);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
-- 
2.7.4



[PATCH 1/3] staging: dgnc: ch->ch_bd is already assigned to bd variable

2017-03-12 Thread Daeseok Youn
The bd variable in dgnc_tty_send_break() is assigned with
ch->ch_bd but it is not used in this function except checking NULL.
The ch->ch_bd could be replaced with bd variable in dgnc_tty_send_break()

Signed-off-by: Daeseok Youn 
---
 drivers/staging/dgnc/dgnc_tty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index cde00e3..c563ee3 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -1799,7 +1799,7 @@ static int dgnc_tty_send_break(struct tty_struct *tty, 
int msec)
 
spin_lock_irqsave(>ch_lock, flags);
 
-   ch->ch_bd->bd_ops->send_break(ch, msec);
+   bd->bd_ops->send_break(ch, msec);
 
spin_unlock_irqrestore(>ch_lock, flags);
 
-- 
2.7.4



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

2016-11-10 Thread Daeseok Youn
Re-arrange the functions for removing forward declarations in dgnc_driver.c

Signed-off-by: Daeseok Youn <daeseok.y...@gmail.com>
---
I've checked the object size of dgnc_driver.c before and after.
It has same size after re-arranging functions.

 drivers/staging/dgnc/dgnc_driver.c | 533 ++---
 1 file changed, 261 insertions(+), 272 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index d3243a3..6f2bffa 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -31,21 +31,6 @@
 MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI 
based product line");
 MODULE_SUPPORTED_DEVICE("dgnc");
 
-/**
- *
- * protos for this file
- *
- */
-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);
-static int dgnc_init_one(struct pci_dev *pdev,
- const struct pci_device_id *ent);
-static int dgnc_do_remap(struct dgnc_board *brd);
-
 /*
  * File operations permitted on Control/Management major.
  */
@@ -114,261 +99,23 @@ struct board_id {
{   NULL,   0,  0   }
 };
 
-static struct pci_driver dgnc_driver = {
-   .name   = "dgnc",
-   .probe  = dgnc_init_one,
-   .id_table   = dgnc_pci_tbl,
-};
-
-/
- *
- * Driver load/unload functions
- *
- /
-
-static void cleanup(bool sysfiles)
-{
-   int i;
-   unsigned long flags;
-
-   spin_lock_irqsave(_poll_lock, flags);
-   dgnc_poll_stop = 1;
-   spin_unlock_irqrestore(_poll_lock, flags);
-
-   /* Turn off poller right away. */
-   del_timer_sync(_poll_timer);
-
-   if (sysfiles)
-   dgnc_remove_driver_sysfiles(_driver);
-
-   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
-   class_destroy(dgnc_class);
-   unregister_chrdev(dgnc_major, "dgnc");
-
-   for (i = 0; i < dgnc_num_boards; ++i) {
-   dgnc_remove_ports_sysfiles(dgnc_board[i]);
-   dgnc_cleanup_tty(dgnc_board[i]);
-   dgnc_cleanup_board(dgnc_board[i]);
-   }
-
-}
-
-/*
- * dgnc_cleanup_module()
- *
- * Module unload.  This is where it all ends.
- */
-static void __exit dgnc_cleanup_module(void)
-{
-   cleanup(true);
-   pci_unregister_driver(_driver);
-}
-
-/*
- * init_module()
- *
- * Module load.  This is where it all starts.
- */
-static int __init dgnc_init_module(void)
-{
-   int rc;
-
-   /*
-* Initialize global stuff
-*/
-   rc = dgnc_start();
-
-   if (rc < 0)
-   return rc;
-
-   /*
-* Find and configure all the cards
-*/
-   rc = pci_register_driver(_driver);
-   if (rc) {
-   pr_warn("WARNING: dgnc driver load failed.  No Digi Neo or 
Classic boards found.\n");
-   cleanup(false);
-   return rc;
-   }
-   dgnc_create_driver_sysfiles(_driver);
-
-   return 0;
-}
 
-module_init(dgnc_init_module);
-module_exit(dgnc_cleanup_module);
 
 /*
- * Start of driver.
+ * Remap PCI memory.
  */
-static int dgnc_start(void)
+static int dgnc_do_remap(struct dgnc_board *brd)
 {
int rc = 0;
-   unsigned long flags;
-   struct device *dev;
-
-   /* make sure timer is initialized before we do anything else */
-   init_timer(_poll_timer);
-
-   /*
-* Register our base character device into the kernel.
-* This allows the download daemon to connect to the downld device
-* before any of the boards are init'ed.
-*
-* Register management/dpa devices
-*/
-   rc = register_chrdev(0, "dgnc", _board_fops);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
-   return rc;
-   }
-   dgnc_major = rc;
-
-   dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
-   if (IS_ERR(dgnc_class)) {
-   rc = PTR_ERR(dgnc_class);
-   pr_err(DRVSTR ": Can't create dgnc_mgmt class (%d)\n", rc);
-   goto failed_class;
-   }
-
-   dev = device_create(dgnc_class, NULL,
-   MKDEV(dgnc_major, 0),
-   NULL, "dgnc_mgmt");
-   if (IS_ERR(dev)) {
-   rc = PTR_ERR(dev);
-   

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

2016-11-10 Thread Daeseok Youn
Re-arrange the functions for removing forward declarations in dgnc_driver.c

Signed-off-by: Daeseok Youn 
---
I've checked the object size of dgnc_driver.c before and after.
It has same size after re-arranging functions.

 drivers/staging/dgnc/dgnc_driver.c | 533 ++---
 1 file changed, 261 insertions(+), 272 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c 
b/drivers/staging/dgnc/dgnc_driver.c
index d3243a3..6f2bffa 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -31,21 +31,6 @@
 MODULE_DESCRIPTION("Driver for the Digi International Neo and Classic PCI 
based product line");
 MODULE_SUPPORTED_DEVICE("dgnc");
 
-/**
- *
- * protos for this file
- *
- */
-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);
-static int dgnc_init_one(struct pci_dev *pdev,
- const struct pci_device_id *ent);
-static int dgnc_do_remap(struct dgnc_board *brd);
-
 /*
  * File operations permitted on Control/Management major.
  */
@@ -114,261 +99,23 @@ struct board_id {
{   NULL,   0,  0   }
 };
 
-static struct pci_driver dgnc_driver = {
-   .name   = "dgnc",
-   .probe  = dgnc_init_one,
-   .id_table   = dgnc_pci_tbl,
-};
-
-/
- *
- * Driver load/unload functions
- *
- /
-
-static void cleanup(bool sysfiles)
-{
-   int i;
-   unsigned long flags;
-
-   spin_lock_irqsave(_poll_lock, flags);
-   dgnc_poll_stop = 1;
-   spin_unlock_irqrestore(_poll_lock, flags);
-
-   /* Turn off poller right away. */
-   del_timer_sync(_poll_timer);
-
-   if (sysfiles)
-   dgnc_remove_driver_sysfiles(_driver);
-
-   device_destroy(dgnc_class, MKDEV(dgnc_major, 0));
-   class_destroy(dgnc_class);
-   unregister_chrdev(dgnc_major, "dgnc");
-
-   for (i = 0; i < dgnc_num_boards; ++i) {
-   dgnc_remove_ports_sysfiles(dgnc_board[i]);
-   dgnc_cleanup_tty(dgnc_board[i]);
-   dgnc_cleanup_board(dgnc_board[i]);
-   }
-
-}
-
-/*
- * dgnc_cleanup_module()
- *
- * Module unload.  This is where it all ends.
- */
-static void __exit dgnc_cleanup_module(void)
-{
-   cleanup(true);
-   pci_unregister_driver(_driver);
-}
-
-/*
- * init_module()
- *
- * Module load.  This is where it all starts.
- */
-static int __init dgnc_init_module(void)
-{
-   int rc;
-
-   /*
-* Initialize global stuff
-*/
-   rc = dgnc_start();
-
-   if (rc < 0)
-   return rc;
-
-   /*
-* Find and configure all the cards
-*/
-   rc = pci_register_driver(_driver);
-   if (rc) {
-   pr_warn("WARNING: dgnc driver load failed.  No Digi Neo or 
Classic boards found.\n");
-   cleanup(false);
-   return rc;
-   }
-   dgnc_create_driver_sysfiles(_driver);
-
-   return 0;
-}
 
-module_init(dgnc_init_module);
-module_exit(dgnc_cleanup_module);
 
 /*
- * Start of driver.
+ * Remap PCI memory.
  */
-static int dgnc_start(void)
+static int dgnc_do_remap(struct dgnc_board *brd)
 {
int rc = 0;
-   unsigned long flags;
-   struct device *dev;
-
-   /* make sure timer is initialized before we do anything else */
-   init_timer(_poll_timer);
-
-   /*
-* Register our base character device into the kernel.
-* This allows the download daemon to connect to the downld device
-* before any of the boards are init'ed.
-*
-* Register management/dpa devices
-*/
-   rc = register_chrdev(0, "dgnc", _board_fops);
-   if (rc < 0) {
-   pr_err(DRVSTR ": Can't register dgnc driver device (%d)\n", rc);
-   return rc;
-   }
-   dgnc_major = rc;
-
-   dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
-   if (IS_ERR(dgnc_class)) {
-   rc = PTR_ERR(dgnc_class);
-   pr_err(DRVSTR ": Can't create dgnc_mgmt class (%d)\n", rc);
-   goto failed_class;
-   }
-
-   dev = device_create(dgnc_class, NULL,
-   MKDEV(dgnc_major, 0),
-   NULL, "dgnc_mgmt");
-   if (IS_ERR(dev)) {
-   rc = PTR_ERR(dev);
-   pr_err(DRVSTR &qu

[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 <daeseok.y...@gmail.com>
---
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_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 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_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 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 <daeseok.y...@gmail.com>
---
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, _tty_ops);
 
-   if (!brd->dgnc_major_serial_registered) {
-   /* Register tty devices */
-   rc = tty_register_driver(brd->serial_driver);
-   if (rc < 0) {
-   dev_dbg(>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(>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, _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(>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(>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);
-   }
-   

[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, _tty_ops);
 
-   if (!brd->dgnc_major_serial_registered) {
-   /* Register tty devices */
-   rc = tty_register_driver(brd->serial_driver);
-   if (rc < 0) {
-   dev_dbg(>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(>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, _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(>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(>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->p

[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 <daeseok.y...@gmail.com>
---
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 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 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 <daeseok.y...@gmail.com>
---
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 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 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 <daeseok.y...@gmail.com>
---
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 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 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 <daeseok.y...@gmail.com>
---
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 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 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 <daeseok.y...@gmail.com>
---
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(>helper_tasklet,
 brd->bd_ops->tasklet,
@@ -539,15 +547,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(>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 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(>helper_tasklet,
 brd->bd_ops->tasklet,
@@ -539,15 +547,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(>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 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 <daeseok.y...@gmail.com>
---
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(>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(>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(>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 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(>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(>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(>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 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 <daeseok.y...@gmail.com>
---
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 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 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 <daeseok.y...@gmail.com>
---
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(_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(>pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(_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(_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(>pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(_global_lock, flags);
-
wake_up_interruptible(>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 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(_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(>pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(_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(_global_lock, flags);
-   brd->msgbuf = NULL;
-   dev_dbg(>pdev->dev, "%s\n", brd->msgbuf_head);
-   kfree(brd->msgbuf_head);
-   brd->msgbuf_head = NULL;
-   spin_unlock_irqrestore(_global_lock, flags);
-
wake_up_interruptible(>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 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 <daeseok.y...@gmail.com>
---
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, >subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, >subdevice);
-- 
1.9.1



[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, >subvendor);
pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, >subdevice);
-- 
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 <gre...@linuxfoundation.org>:
> 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 <daeseok.y...@gmail.com>
>> ---
>> 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


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 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 <daeseok.y...@gmail.com>
---
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



[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



[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 <daeseok.y...@gmail.com>
---
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 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 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 <daeseok.y...@gmail.com>
---
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(>helper_tasklet,
 brd->bd_ops->tasklet,
@@ -539,15 +547,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
wake_up_interruptible(>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



  1   2   3   4   5   6   7   8   9   10   >