[PATCH 1/9] staging: dgap: remove unused paramter in dgap_parsefile()

2014-06-13 Thread Daeseok Youn
remove parameter is not used in dgap_parsefile().

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 38749d0..c1f2798 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -174,7 +174,7 @@ static void dgap_remove_tty_sysfs(struct device *c);
 /*
  * Function prototypes from dgap_parse.h
  */
-static int dgap_parsefile(char **in, int remove);
+static int dgap_parsefile(char **in);
 static struct cnode *dgap_find_config(int type, int bus, int slot);
 static uint dgap_config_get_num_prts(struct board_t *bd);
 static char *dgap_create_config_string(struct board_t *bd, char *string);
@@ -852,7 +852,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
 */
tmp_ptr = dgap_config_buf;
 
-   if (dgap_parsefile(tmp_ptr, TRUE) != 0) {
+   if (dgap_parsefile(tmp_ptr) != 0) {
kfree(dgap_config_buf);
return -EINVAL;
}
@@ -6427,7 +6427,7 @@ static void dgap_remove_tty_sysfs(struct device *c)
 /*
  * Parse a configuration file read into memory as a string.
  */
-static int dgap_parsefile(char **in, int remove)
+static int dgap_parsefile(char **in)
 {
struct cnode *p, *brd, *line, *conc;
int rc;
-- 
1.7.1

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


[PATCH 2/9] staging: dgap: get rid of brd-firstminor because it is 0

2014-06-13 Thread Daeseok Youn
firstminor in struct borad_t is always zero, so it
can be removed.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index c1f2798..352eb1b 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -684,7 +684,6 @@ static int dgap_found_board(struct pci_dev *pdev, int id, 
int boardnum)
/* store the info for the board we've found */
brd-magic = DGAP_BOARD_MAGIC;
brd-boardnum = boardnum;
-   brd-firstminor = 0;
brd-vendor = dgap_pci_tbl[id].vendor;
brd-device = dgap_pci_tbl[id].device;
brd-pdev = pdev;
@@ -4168,8 +4167,8 @@ static int dgap_tty_register_ports(struct board_t *brd)
struct device *classp;
 
classp = tty_port_register_device(brd-serial_ports[i],
-   brd-serial_driver,
-   brd-firstminor + i, NULL);
+ brd-serial_driver,
+ i, NULL);
 
if (IS_ERR(classp)) {
ret = PTR_ERR(classp);
@@ -4180,8 +4179,8 @@ static int dgap_tty_register_ports(struct board_t *brd)
ch-ch_tun.un_sysfs = classp;
 
classp = tty_port_register_device(brd-printer_ports[i],
-   brd-print_driver,
-   brd-firstminor + i, NULL);
+ brd-print_driver,
+ i, NULL);
 
if (IS_ERR(classp)) {
ret = PTR_ERR(classp);
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index 03c020e..c00b2e2 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -529,7 +529,6 @@ struct macounter {
 struct board_t {
int magic;  /* Board Magic number.  */
int boardnum;   /* Board number: 0-3 */
-   int firstminor; /* First minor, e.g. 0, 30, 60 */
 
int type;   /* Type of board */
char*name;  /* Product Name */
-- 
1.7.1

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


[PATCH 3/9] staging: dgap: introduce dgap_tty_free() for freeing channels.

2014-06-13 Thread Daeseok Youn
It should be called after dgap_tty_register_ports() is failed.
So channels which are allocated in dgap_tty_init() will be freed.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 352eb1b..eab8fd5 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -123,6 +123,7 @@ static void dgap_tty_send_xchar(struct tty_struct *tty, 
char ch);
 
 static int dgap_tty_register(struct board_t *brd);
 static int dgap_tty_init(struct board_t *);
+static void dgap_tty_free(struct board_t *);
 static void dgap_cleanup_tty(struct board_t *);
 static void dgap_carrier(struct channel_t *ch);
 static void dgap_input(struct channel_t *ch);
@@ -960,8 +961,10 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
return ret;
 
ret = dgap_tty_register_ports(brd);
-   if (ret)
+   if (ret) {
+   dgap_tty_free(brd);
return ret;
+   }
 
brd-state = BOARD_READY;
brd-dpastatus = BD_RUNNING;
@@ -1488,6 +1491,18 @@ free_chan:
 }
 
 /*
+ * dgap_tty_free()
+ *
+ * Free the channles which are allocated in dgap_tty_init().
+ */
+static void dgap_tty_free(struct board_t *brd)
+{
+   int i;
+
+   for (i = 0; i  brd-nasync; i++)
+   kfree(brd-channels[i]);
+}
+/*
  * dgap_cleanup_tty()
  *
  * Uninitialize the TTY portion of this driver.  Free all memory and
-- 
1.7.1

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


[PATCH 4/9] staging: dgap: introduce dgap_free_irq()

2014-06-13 Thread Daeseok Youn
dgap_free_irq() will free the irq which is requested in
dgap_request_irq().

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index eab8fd5..497e6f3 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -190,6 +190,7 @@ static void dgap_do_conc_load(struct board_t *brd, u8 
*uaddr, int len);
 #endif
 static int dgap_after_config_loaded(struct board_t *brd);
 static int dgap_request_irq(struct board_t *brd);
+static void dgap_free_irq(struct board_t *brd);
 
 static void dgap_get_vpd(struct board_t *brd);
 static void dgap_do_reset_board(struct board_t *brd);
@@ -634,8 +635,7 @@ static void dgap_cleanup_board(struct board_t *brd)
if (!brd || brd-magic != DGAP_BOARD_MAGIC)
return;
 
-   if (brd-intr_used  brd-irq)
-   free_irq(brd-irq, brd);
+   dgap_free_irq(brd);
 
tasklet_kill(brd-helper_tasklet);
 
@@ -816,6 +816,12 @@ static int dgap_request_irq(struct board_t *brd)
return 0;
 }
 
+static void dgap_free_irq(struct board_t *brd)
+{
+   if (brd-intr_used  brd-irq)
+   free_irq(brd-irq, brd);
+}
+
 static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
 {
struct board_t *brd = dgap_board[dgap_numboards - 1];
-- 
1.7.1

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


[PATCH 5/9] staging: dgap: introduce dgap_tty_unregister()

2014-06-13 Thread Daeseok Youn
dgap_tty_unregister() will unregister serial_driver
and print_driver, and also free related variables.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 497e6f3..4ea7a33 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -122,6 +122,7 @@ static int dgap_tty_put_char(struct tty_struct *tty, 
unsigned char c);
 static void dgap_tty_send_xchar(struct tty_struct *tty, char ch);
 
 static int dgap_tty_register(struct board_t *brd);
+static void dgap_tty_unregister(struct board_t *brd);
 static int dgap_tty_init(struct board_t *);
 static void dgap_tty_free(struct board_t *);
 static void dgap_cleanup_tty(struct board_t *);
@@ -1320,6 +1321,14 @@ free_serial_drv:
return rc;
 }
 
+static void dgap_tty_unregister(struct board_t *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);
+}
+
 /*
  * dgap_tty_init()
  *
-- 
1.7.1

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


[PATCH 6/9] staging: dgap: rename dgap_after_config_loaded() to dgap_alloc_flipbuf()

2014-06-13 Thread Daeseok Youn
dgap_after_config_loaded() as function name doesn't tell
what it does.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 4ea7a33..db8c93b 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -189,7 +189,7 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 
*ufep, int len);
 #ifdef DIGI_CONCENTRATORS_SUPPORTED
 static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len);
 #endif
-static int dgap_after_config_loaded(struct board_t *brd);
+static int dgap_alloc_flipbuf(struct board_t *brd);
 static int dgap_request_irq(struct board_t *brd);
 static void dgap_free_irq(struct board_t *brd);
 
@@ -866,7 +866,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
kfree(dgap_config_buf);
}
 
-   ret = dgap_after_config_loaded(brd);
+   ret = dgap_alloc_flipbuf(brd);
if (ret)
return ret;
/*
@@ -4142,7 +4142,7 @@ static int dgap_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
}
 }
 
-static int dgap_after_config_loaded(struct board_t *brd)
+static int dgap_alloc_flipbuf(struct board_t *brd)
 {
/*
 * Initialize KME waitqueues...
-- 
1.7.1

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


[PATCH 7/9] staging: dgap: introduce dgap_free_flipbuf()

2014-06-13 Thread Daeseok Youn
dgap_free_flipbuf() will free flipbuf and flipflagbuf which
are allocated in dgap_alloc_flipbuf()

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index db8c93b..c0016bd 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -190,6 +190,7 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 
*ufep, int len);
 static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len);
 #endif
 static int dgap_alloc_flipbuf(struct board_t *brd);
+static void dgap_free_flipbuf(struct board_t *brd);
 static int dgap_request_irq(struct board_t *brd);
 static void dgap_free_irq(struct board_t *brd);
 
@@ -4165,6 +4166,12 @@ static int dgap_alloc_flipbuf(struct board_t *brd)
return 0;
 }
 
+static void dgap_free_flipbuf(struct board_t *brd)
+{
+   kfree(brd-flipbuf);
+   kfree(brd-flipflagbuf);
+}
+
 /*
  * Create pr and tty device entries
  */
-- 
1.7.1

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


[PATCH 8/9] staging: dgap: cleanup dgap_firmware_load() function

2014-06-13 Thread Daeseok Youn
The dgap_firmware_load() has a lot of stuff beside
loding firmware. So some registering and initializing
for device are moved into dgap_init_one().

And also adds unwinding on error in dgap_init_one().

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index c0016bd..e1347fb 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -199,7 +199,8 @@ static void dgap_do_reset_board(struct board_t *brd);
 static int dgap_test_bios(struct board_t *brd);
 static int dgap_test_fep(struct board_t *brd);
 static int dgap_tty_register_ports(struct board_t *brd);
-static int dgap_firmware_load(struct pci_dev *pdev, int card_type);
+static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
+ struct board_t* brd);
 
 static void dgap_cleanup_module(void);
 
@@ -571,6 +572,7 @@ static int dgap_init_pci(void)
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
int rc;
+   struct board_t* brd;
 
if (dgap_numboards = MAXBOARDS)
return -EPERM;
@@ -583,8 +585,51 @@ static int dgap_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (rc)
return rc;
 
-   dgap_numboards++;
-   return dgap_firmware_load(pdev, ent-driver_data);
+   brd = dgap_board[dgap_numboards++];
+   rc = dgap_firmware_load(pdev, ent-driver_data, brd);
+   if (rc)
+   goto free_brd;
+
+   rc = dgap_alloc_flipbuf(brd);
+   if (rc)
+   goto free_brd;
+
+   rc = dgap_tty_register(brd);
+   if (rc)
+   goto free_flipbuf;
+
+   rc = dgap_request_irq(brd);
+   if (rc)
+   goto unregister_tty;
+
+   /*
+* Do tty device initialization.
+*/
+   rc = dgap_tty_init(brd);
+   if (rc  0)
+   goto free_irq;
+
+   rc = dgap_tty_register_ports(brd);
+   if (rc)
+   goto tty_free;
+
+   brd-state = BOARD_READY;
+   brd-dpastatus = BD_RUNNING;
+
+   return 0;
+
+tty_free:
+   dgap_tty_free(brd);
+free_irq:
+   dgap_free_irq(brd);
+unregister_tty:
+   dgap_tty_unregister(brd);
+free_flipbuf:
+   dgap_free_flipbuf(brd);
+free_brd:
+   kfree(brd);
+   dgap_board[--dgap_numboards] = NULL;
+   return rc;
 }
 
 static void dgap_remove_one(struct pci_dev *dev)
@@ -824,9 +869,9 @@ static void dgap_free_irq(struct board_t *brd)
free_irq(brd-irq, brd);
 }
 
-static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
+static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
+ struct board_t* brd)
 {
-   struct board_t *brd = dgap_board[dgap_numboards - 1];
const struct firmware *fw;
char *tmp_ptr;
int ret;
@@ -867,9 +912,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
kfree(dgap_config_buf);
}
 
-   ret = dgap_alloc_flipbuf(brd);
-   if (ret)
-   return ret;
/*
 * Match this board to a config the user created for us.
 */
@@ -891,14 +933,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
return -EINVAL;
}
 
-   ret = dgap_tty_register(brd);
-   if (ret)
-   return ret;
-
-   ret = dgap_request_irq(brd);
-   if (ret)
-   return ret;
-
if (fw_info[card_type].bios_name) {
ret = request_firmware(fw, fw_info[card_type].bios_name,
pdev-dev);
@@ -961,21 +995,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
release_firmware(fw);
}
 #endif
-   /*
-* Do tty device initialization.
-*/
-   ret = dgap_tty_init(brd);
-   if (ret  0)
-   return ret;
-
-   ret = dgap_tty_register_ports(brd);
-   if (ret) {
-   dgap_tty_free(brd);
-   return ret;
-   }
-
-   brd-state = BOARD_READY;
-   brd-dpastatus = BD_RUNNING;
 
return 0;
 }
-- 
1.7.1

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


[PATCH 9/9] staging: dgap: introduce dgap_release_remap()

2014-06-13 Thread Daeseok Youn
The dgap_found_board() did request some memory region and
call ioremap, these should be released and unmaped
when one of functions which are called after dgap_found_board()
in dgap_init_one() is failed.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index e1347fb..5c8e622 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -77,6 +77,7 @@ static int dgap_init_pci(void);
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id 
*ent);
 static void dgap_remove_one(struct pci_dev *dev);
 static int dgap_do_remap(struct board_t *brd);
+static void dgap_release_remap(struct board_t *brd);
 static irqreturn_t dgap_intr(int irq, void *voidbrd);
 
 static int dgap_tty_open(struct tty_struct *tty, struct file *file);
@@ -588,11 +589,11 @@ static int dgap_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
brd = dgap_board[dgap_numboards++];
rc = dgap_firmware_load(pdev, ent-driver_data, brd);
if (rc)
-   goto free_brd;
+   goto cleanup_brd;
 
rc = dgap_alloc_flipbuf(brd);
if (rc)
-   goto free_brd;
+   goto cleanup_brd;
 
rc = dgap_tty_register(brd);
if (rc)
@@ -626,7 +627,8 @@ unregister_tty:
dgap_tty_unregister(brd);
 free_flipbuf:
dgap_free_flipbuf(brd);
-free_brd:
+cleanup_brd:
+   dgap_release_remap(brd);
kfree(brd);
dgap_board[--dgap_numboards] = NULL;
return rc;
@@ -1034,6 +1036,12 @@ static int dgap_do_remap(struct board_t *brd)
return 0;
 }
 
+static void dgap_release_remap(struct board_t *brd)
+{
+   release_mem_region(brd-membase, 0x20);
+   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
+   iounmap(brd-re_map_membase);
+}
 /*
 *
 * Function:
-- 
1.7.1

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


Re: [PATCH 5/9] staging: dgap: introduce dgap_tty_unregister()

2014-06-13 Thread Dan Carpenter
On Fri, Jun 13, 2014 at 04:41:47PM +0900, Daeseok Youn wrote:
 dgap_tty_unregister() will unregister serial_driver
 and print_driver, and also free related variables.
 

Introducing a static function without a caller will cause a GCC warning
about unused functions.

Fold 5,7 and 8 together into one patch.  This is still one thing per
patch because they can't be done separately.

regards,
dan carpenter

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


Re: [PATCH 5/9] staging: dgap: introduce dgap_tty_unregister()

2014-06-13 Thread DaeSeok Youn
Hi, Dan



2014-06-13 17:00 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 On Fri, Jun 13, 2014 at 04:41:47PM +0900, Daeseok Youn wrote:
 dgap_tty_unregister() will unregister serial_driver
 and print_driver, and also free related variables.


 Introducing a static function without a caller will cause a GCC warning
 about unused functions.

 Fold 5,7 and 8 together into one patch.  This is still one thing per
 patch because they can't be done separately.
OK. I will do. And then this series of patches will resend, right?

Thanks.

regards,
Daeseok Youn

 regards,
 dan carpenter

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


Re: [PATCH 8/9] staging: dgap: cleanup dgap_firmware_load() function

2014-06-13 Thread Dan Carpenter
On Fri, Jun 13, 2014 at 04:43:37PM +0900, Daeseok Youn wrote:
 @@ -583,8 +585,51 @@ static int dgap_init_one(struct pci_dev *pdev, const 
 struct pci_device_id *ent)
   if (rc)
   return rc;
  
 - dgap_numboards++;
 - return dgap_firmware_load(pdev, ent-driver_data);
 + brd = dgap_board[dgap_numboards++];

I don't like the way the current code uses dgap_numboards and hiding
the ++ in here makes it even worse.

My thinking is that dgap_found_board() shouldn't touch dgap_board[] but
instead of instead it should return a pointer to brd.  Then the code
in dgap_init_one() does:

brd = dgap_found_board();
if (!brd)
return -ENODEV;

/* code until the end of the function */

dgap_board[dgap_numboards++] = brd;
return 0;

tty_free:
/* error path */

This could be done in a follow on patch.

TODO-list: 2014-06-13: dgap: make dgap_found_board() return a brd pointer.

 + rc = dgap_firmware_load(pdev, ent-driver_data, brd);
 + if (rc)
 + goto free_brd;
 +
 + rc = dgap_alloc_flipbuf(brd);
 + if (rc)
 + goto free_brd;
 +
 + rc = dgap_tty_register(brd);
 + if (rc)
 + goto free_flipbuf;
 +
 + rc = dgap_request_irq(brd);
 + if (rc)
 + goto unregister_tty;
 +
 + /*
 +  * Do tty device initialization.
 +  */
 + rc = dgap_tty_init(brd);
 + if (rc  0)
 + goto free_irq;
 +
 + rc = dgap_tty_register_ports(brd);
 + if (rc)
 + goto tty_free;
 +
 + brd-state = BOARD_READY;
 + brd-dpastatus = BD_RUNNING;
 +
 + return 0;
 +
 +tty_free:
 + dgap_tty_free(brd);
 +free_irq:
 + dgap_free_irq(brd);
 +unregister_tty:
 + dgap_tty_unregister(brd);
 +free_flipbuf:
 + dgap_free_flipbuf(brd);
 +free_brd:
 + kfree(brd);

This isn't complete.  We need a dgap_unfound_board() which frees brd
and calls the inverse of dgap_do_remap().  Obviously found and
unfound are not the smartest names in the universe.

That said, I'm inclined to say that we can fix this up in a later patch.
This patch is clearly an improvement on the existing code and I'm not
sure it's possible to fix *everything* in one go.

TODO-list:  2014-06-13: dgap: call dgap_unfound_board() on error in 
dgap_init_one()

 + dgap_board[--dgap_numboards] = NULL;
 + return rc;
  }

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


Re: [PATCH 9/9] staging: dgap: introduce dgap_release_remap()

2014-06-13 Thread Dan Carpenter
On Fri, Jun 13, 2014 at 04:44:11PM +0900, Daeseok Youn wrote:
 The dgap_found_board() did request some memory region and
 call ioremap, these should be released and unmaped
 when one of functions which are called after dgap_found_board()
 in dgap_init_one() is failed.
 

Oh...  Here you clean up the rest that I mentioned in reviewing 8/9.

Fine fine.

regards,
dan carpenter

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


Re: [PATCH 5/9] staging: dgap: introduce dgap_tty_unregister()

2014-06-13 Thread Dan Carpenter
On Fri, Jun 13, 2014 at 05:16:27PM +0900, DaeSeok Youn wrote:
 Hi, Dan
 
 
 
 2014-06-13 17:00 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
  On Fri, Jun 13, 2014 at 04:41:47PM +0900, Daeseok Youn wrote:
  dgap_tty_unregister() will unregister serial_driver
  and print_driver, and also free related variables.
 
 
  Introducing a static function without a caller will cause a GCC warning
  about unused functions.
 
  Fold 5,7 and 8 together into one patch.  This is still one thing per
  patch because they can't be done separately.
 OK. I will do. And then this series of patches will resend, right?

I'm afraid so.  New GCC warnings are against the rules even if you fix
it in a later patch.

Since you're redoing it, can I suggest that patch 8 should just move
the code to dgap_init_one() and change the dgap_firmware_load()
prototype and then another patch should add the error handling.

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


Re: [PATCH 5/9] staging: dgap: introduce dgap_tty_unregister()

2014-06-13 Thread DaeSeok Youn
2014-06-13 17:38 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
 On Fri, Jun 13, 2014 at 05:16:27PM +0900, DaeSeok Youn wrote:
 Hi, Dan



 2014-06-13 17:00 GMT+09:00 Dan Carpenter dan.carpen...@oracle.com:
  On Fri, Jun 13, 2014 at 04:41:47PM +0900, Daeseok Youn wrote:
  dgap_tty_unregister() will unregister serial_driver
  and print_driver, and also free related variables.
 
 
  Introducing a static function without a caller will cause a GCC warning
  about unused functions.
 
  Fold 5,7 and 8 together into one patch.  This is still one thing per
  patch because they can't be done separately.
 OK. I will do. And then this series of patches will resend, right?

 I'm afraid so.  New GCC warnings are against the rules even if you fix
 it in a later patch.

 Since you're redoing it, can I suggest that patch 8 should just move
 the code to dgap_init_one() and change the dgap_firmware_load()
 prototype and then another patch should add the error handling.
Ok. I will do as your comment.

Thanks.

regards,
Daeseok Youn

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


[PATCH 1/7 RESEND] staging: dgap: remove unused paramter in dgap_parsefile()

2014-06-13 Thread Daeseok Youn
remove parameter is not used in dgap_parsefile().

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
resend: reorder this series of patches

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 38749d0..c1f2798 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -174,7 +174,7 @@ static void dgap_remove_tty_sysfs(struct device *c);
 /*
  * Function prototypes from dgap_parse.h
  */
-static int dgap_parsefile(char **in, int remove);
+static int dgap_parsefile(char **in);
 static struct cnode *dgap_find_config(int type, int bus, int slot);
 static uint dgap_config_get_num_prts(struct board_t *bd);
 static char *dgap_create_config_string(struct board_t *bd, char *string);
@@ -852,7 +852,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
 */
tmp_ptr = dgap_config_buf;
 
-   if (dgap_parsefile(tmp_ptr, TRUE) != 0) {
+   if (dgap_parsefile(tmp_ptr) != 0) {
kfree(dgap_config_buf);
return -EINVAL;
}
@@ -6427,7 +6427,7 @@ static void dgap_remove_tty_sysfs(struct device *c)
 /*
  * Parse a configuration file read into memory as a string.
  */
-static int dgap_parsefile(char **in, int remove)
+static int dgap_parsefile(char **in)
 {
struct cnode *p, *brd, *line, *conc;
int rc;
-- 
1.7.1

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


[PATCH 2/7 RESEND] staging: dgap: get rid of brd-firstminor because it is 0

2014-06-13 Thread Daeseok Youn
firstminor in struct borad_t is always zero, so it
can be removed.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
resend: reordering this series of patches

 drivers/staging/dgap/dgap.c |9 -
 drivers/staging/dgap/dgap.h |1 -
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index c1f2798..352eb1b 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -684,7 +684,6 @@ static int dgap_found_board(struct pci_dev *pdev, int id, 
int boardnum)
/* store the info for the board we've found */
brd-magic = DGAP_BOARD_MAGIC;
brd-boardnum = boardnum;
-   brd-firstminor = 0;
brd-vendor = dgap_pci_tbl[id].vendor;
brd-device = dgap_pci_tbl[id].device;
brd-pdev = pdev;
@@ -4168,8 +4167,8 @@ static int dgap_tty_register_ports(struct board_t *brd)
struct device *classp;
 
classp = tty_port_register_device(brd-serial_ports[i],
-   brd-serial_driver,
-   brd-firstminor + i, NULL);
+ brd-serial_driver,
+ i, NULL);
 
if (IS_ERR(classp)) {
ret = PTR_ERR(classp);
@@ -4180,8 +4179,8 @@ static int dgap_tty_register_ports(struct board_t *brd)
ch-ch_tun.un_sysfs = classp;
 
classp = tty_port_register_device(brd-printer_ports[i],
-   brd-print_driver,
-   brd-firstminor + i, NULL);
+ brd-print_driver,
+ i, NULL);
 
if (IS_ERR(classp)) {
ret = PTR_ERR(classp);
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index 03c020e..c00b2e2 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -529,7 +529,6 @@ struct macounter {
 struct board_t {
int magic;  /* Board Magic number.  */
int boardnum;   /* Board number: 0-3 */
-   int firstminor; /* First minor, e.g. 0, 30, 60 */
 
int type;   /* Type of board */
char*name;  /* Product Name */
-- 
1.7.1

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


[PATCH 3/7 RESEND] staging: dgap: introduce dgap_tty_free() for freeing channels.

2014-06-13 Thread Daeseok Youn
It should be called after dgap_tty_register_ports() is failed.
So channels which are allocated in dgap_tty_init() will be freed.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
resend: reordering this series of patches

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 352eb1b..eab8fd5 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -123,6 +123,7 @@ static void dgap_tty_send_xchar(struct tty_struct *tty, 
char ch);
 
 static int dgap_tty_register(struct board_t *brd);
 static int dgap_tty_init(struct board_t *);
+static void dgap_tty_free(struct board_t *);
 static void dgap_cleanup_tty(struct board_t *);
 static void dgap_carrier(struct channel_t *ch);
 static void dgap_input(struct channel_t *ch);
@@ -960,8 +961,10 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
return ret;
 
ret = dgap_tty_register_ports(brd);
-   if (ret)
+   if (ret) {
+   dgap_tty_free(brd);
return ret;
+   }
 
brd-state = BOARD_READY;
brd-dpastatus = BD_RUNNING;
@@ -1488,6 +1491,18 @@ free_chan:
 }
 
 /*
+ * dgap_tty_free()
+ *
+ * Free the channles which are allocated in dgap_tty_init().
+ */
+static void dgap_tty_free(struct board_t *brd)
+{
+   int i;
+
+   for (i = 0; i  brd-nasync; i++)
+   kfree(brd-channels[i]);
+}
+/*
  * dgap_cleanup_tty()
  *
  * Uninitialize the TTY portion of this driver.  Free all memory and
-- 
1.7.1

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


[PATCH 4/7 RESEND] staging: dgap: introduce dgap_free_irq()

2014-06-13 Thread Daeseok Youn
dgap_free_irq() will free the irq which is requested in
dgap_request_irq().

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
resend: reordering this series of patches, because some patches are
merged to one.

 drivers/staging/dgap/dgap.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index eab8fd5..497e6f3 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -190,6 +190,7 @@ static void dgap_do_conc_load(struct board_t *brd, u8 
*uaddr, int len);
 #endif
 static int dgap_after_config_loaded(struct board_t *brd);
 static int dgap_request_irq(struct board_t *brd);
+static void dgap_free_irq(struct board_t *brd);
 
 static void dgap_get_vpd(struct board_t *brd);
 static void dgap_do_reset_board(struct board_t *brd);
@@ -634,8 +635,7 @@ static void dgap_cleanup_board(struct board_t *brd)
if (!brd || brd-magic != DGAP_BOARD_MAGIC)
return;
 
-   if (brd-intr_used  brd-irq)
-   free_irq(brd-irq, brd);
+   dgap_free_irq(brd);
 
tasklet_kill(brd-helper_tasklet);
 
@@ -816,6 +816,12 @@ static int dgap_request_irq(struct board_t *brd)
return 0;
 }
 
+static void dgap_free_irq(struct board_t *brd)
+{
+   if (brd-intr_used  brd-irq)
+   free_irq(brd-irq, brd);
+}
+
 static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
 {
struct board_t *brd = dgap_board[dgap_numboards - 1];
-- 
1.7.1

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


[PATCH 5/7 RESEND] staging: dgap: rename dgap_after_config_loaded() to dgap_alloc_flipbuf()

2014-06-13 Thread Daeseok Youn
dgap_after_config_loaded() as function name doesn't tell
what it does.

Signed-off-by: Daeseok Youn daeseok.y...@gmail.com
---
resend: reordering this series of patches, becasue some patches
are merged into one.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 497e6f3..721404f 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -188,7 +188,7 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 
*ufep, int len);
 #ifdef DIGI_CONCENTRATORS_SUPPORTED
 static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len);
 #endif
-static int dgap_after_config_loaded(struct board_t *brd);
+static int dgap_alloc_flipbuf(struct board_t *brd);
 static int dgap_request_irq(struct board_t *brd);
 static void dgap_free_irq(struct board_t *brd);
 
@@ -865,7 +865,7 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
kfree(dgap_config_buf);
}
 
-   ret = dgap_after_config_loaded(brd);
+   ret = dgap_alloc_flipbuf(brd);
if (ret)
return ret;
/*
@@ -4133,7 +4133,7 @@ static int dgap_tty_ioctl(struct tty_struct *tty, 
unsigned int cmd,
}
 }
 
-static int dgap_after_config_loaded(struct board_t *brd)
+static int dgap_alloc_flipbuf(struct board_t *brd)
 {
/*
 * Initialize KME waitqueues...
-- 
1.7.1

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


[PATCH 6/7] staging: dgap: move unrelated functions in dgap_firmware_load()

2014-06-13 Thread Daeseok Youn
The dgap_firmware_load() has a lot of stuff which are
unrelated with loading firmware.
So just moved to dgap_init_one().

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 721404f..2ccbd54 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -197,7 +197,8 @@ static void dgap_do_reset_board(struct board_t *brd);
 static int dgap_test_bios(struct board_t *brd);
 static int dgap_test_fep(struct board_t *brd);
 static int dgap_tty_register_ports(struct board_t *brd);
-static int dgap_firmware_load(struct pci_dev *pdev, int card_type);
+static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
+ struct board_t* brd);
 
 static void dgap_cleanup_module(void);
 
@@ -569,6 +570,7 @@ static int dgap_init_pci(void)
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
int rc;
+   struct board_t* brd;
 
if (dgap_numboards = MAXBOARDS)
return -EPERM;
@@ -581,8 +583,40 @@ static int dgap_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (rc)
return rc;
 
-   dgap_numboards++;
-   return dgap_firmware_load(pdev, ent-driver_data);
+   brd = dgap_board[dgap_numboards++];
+   rc = dgap_firmware_load(pdev, ent-driver_data, brd);
+   if (rc)
+   return rc;
+
+   rc = dgap_alloc_flipbuf(brd);
+   if (rc)
+   return rc;
+
+   rc = dgap_tty_register(brd);
+   if (rc)
+   return rc;
+
+   rc = dgap_request_irq(brd);
+   if (rc)
+   return rc;
+
+   /*
+* Do tty device initialization.
+*/
+   rc = dgap_tty_init(brd);
+   if (rc  0)
+   return rc;
+
+   rc = dgap_tty_register_ports(brd);
+   if (rc) {
+   dgap_tty_free(brd);
+   return rc;
+   }
+
+   brd-state = BOARD_READY;
+   brd-dpastatus = BD_RUNNING;
+
+   return 0;
 }
 
 static void dgap_remove_one(struct pci_dev *dev)
@@ -822,9 +856,9 @@ static void dgap_free_irq(struct board_t *brd)
free_irq(brd-irq, brd);
 }
 
-static int dgap_firmware_load(struct pci_dev *pdev, int card_type)
+static int dgap_firmware_load(struct pci_dev *pdev, int card_type,
+ struct board_t* brd)
 {
-   struct board_t *brd = dgap_board[dgap_numboards - 1];
const struct firmware *fw;
char *tmp_ptr;
int ret;
@@ -865,9 +899,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
kfree(dgap_config_buf);
}
 
-   ret = dgap_alloc_flipbuf(brd);
-   if (ret)
-   return ret;
/*
 * Match this board to a config the user created for us.
 */
@@ -889,14 +920,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
return -EINVAL;
}
 
-   ret = dgap_tty_register(brd);
-   if (ret)
-   return ret;
-
-   ret = dgap_request_irq(brd);
-   if (ret)
-   return ret;
-
if (fw_info[card_type].bios_name) {
ret = request_firmware(fw, fw_info[card_type].bios_name,
pdev-dev);
@@ -959,21 +982,6 @@ static int dgap_firmware_load(struct pci_dev *pdev, int 
card_type)
release_firmware(fw);
}
 #endif
-   /*
-* Do tty device initialization.
-*/
-   ret = dgap_tty_init(brd);
-   if (ret  0)
-   return ret;
-
-   ret = dgap_tty_register_ports(brd);
-   if (ret) {
-   dgap_tty_free(brd);
-   return ret;
-   }
-
-   brd-state = BOARD_READY;
-   brd-dpastatus = BD_RUNNING;
 
return 0;
 }
-- 
1.7.1

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


[PATCH 7/7] staging: dgap: unwind on error in dgap_init_one()

2014-06-13 Thread Daeseok Youn
The dgap_init_one() needs to handle error properly
if one of functions in dgap_init_one() is failed.

Introduce some functions for handling error in dgap_init_one()
 - dgap_tty_unregister() : unregister tty driver
 - dgap_free_flipbuf() : free flip buffer
 - dgap_release_remap() : release memory region and unmapped memory.

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

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 2ccbd54..5c8e622 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -77,6 +77,7 @@ static int dgap_init_pci(void);
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id 
*ent);
 static void dgap_remove_one(struct pci_dev *dev);
 static int dgap_do_remap(struct board_t *brd);
+static void dgap_release_remap(struct board_t *brd);
 static irqreturn_t dgap_intr(int irq, void *voidbrd);
 
 static int dgap_tty_open(struct tty_struct *tty, struct file *file);
@@ -122,6 +123,7 @@ static int dgap_tty_put_char(struct tty_struct *tty, 
unsigned char c);
 static void dgap_tty_send_xchar(struct tty_struct *tty, char ch);
 
 static int dgap_tty_register(struct board_t *brd);
+static void dgap_tty_unregister(struct board_t *brd);
 static int dgap_tty_init(struct board_t *);
 static void dgap_tty_free(struct board_t *);
 static void dgap_cleanup_tty(struct board_t *);
@@ -189,6 +191,7 @@ static void dgap_do_fep_load(struct board_t *brd, const u8 
*ufep, int len);
 static void dgap_do_conc_load(struct board_t *brd, u8 *uaddr, int len);
 #endif
 static int dgap_alloc_flipbuf(struct board_t *brd);
+static void dgap_free_flipbuf(struct board_t *brd);
 static int dgap_request_irq(struct board_t *brd);
 static void dgap_free_irq(struct board_t *brd);
 
@@ -586,37 +589,49 @@ static int dgap_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
brd = dgap_board[dgap_numboards++];
rc = dgap_firmware_load(pdev, ent-driver_data, brd);
if (rc)
-   return rc;
+   goto cleanup_brd;
 
rc = dgap_alloc_flipbuf(brd);
if (rc)
-   return rc;
+   goto cleanup_brd;
 
rc = dgap_tty_register(brd);
if (rc)
-   return rc;
+   goto free_flipbuf;
 
rc = dgap_request_irq(brd);
if (rc)
-   return rc;
+   goto unregister_tty;
 
/*
 * Do tty device initialization.
 */
rc = dgap_tty_init(brd);
if (rc  0)
-   return rc;
+   goto free_irq;
 
rc = dgap_tty_register_ports(brd);
-   if (rc) {
-   dgap_tty_free(brd);
-   return rc;
-   }
+   if (rc)
+   goto tty_free;
 
brd-state = BOARD_READY;
brd-dpastatus = BD_RUNNING;
 
return 0;
+
+tty_free:
+   dgap_tty_free(brd);
+free_irq:
+   dgap_free_irq(brd);
+unregister_tty:
+   dgap_tty_unregister(brd);
+free_flipbuf:
+   dgap_free_flipbuf(brd);
+cleanup_brd:
+   dgap_release_remap(brd);
+   kfree(brd);
+   dgap_board[--dgap_numboards] = NULL;
+   return rc;
 }
 
 static void dgap_remove_one(struct pci_dev *dev)
@@ -1021,6 +1036,12 @@ static int dgap_do_remap(struct board_t *brd)
return 0;
 }
 
+static void dgap_release_remap(struct board_t *brd)
+{
+   release_mem_region(brd-membase, 0x20);
+   release_mem_region(brd-membase + PCI_IO_OFFSET, 0x20);
+   iounmap(brd-re_map_membase);
+}
 /*
 *
 * Function:
@@ -1328,6 +1349,14 @@ free_serial_drv:
return rc;
 }
 
+static void dgap_tty_unregister(struct board_t *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);
+}
+
 /*
  * dgap_tty_init()
  *
@@ -4164,6 +4193,12 @@ static int dgap_alloc_flipbuf(struct board_t *brd)
return 0;
 }
 
+static void dgap_free_flipbuf(struct board_t *brd)
+{
+   kfree(brd-flipbuf);
+   kfree(brd-flipflagbuf);
+}
+
 /*
  * Create pr and tty device entries
  */
-- 
1.7.1

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


[PATCH] staging: vt6655: remove unnecessary typedef struct.

2014-06-13 Thread Martin Kepplinger
Remove a totally unnecessary typedef. This is more readable now.

Signed-off-by: Martin Kepplinger mart...@posteo.de
---
applies to next-20140611

 drivers/staging/vt6655/card.c   |2 +-
 drivers/staging/vt6655/device.h |6 +++---
 drivers/staging/vt6655/wmgr.c   |2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c
index 05bf48a..765b5eb 100644
--- a/drivers/staging/vt6655/card.c
+++ b/drivers/staging/vt6655/card.c
@@ -998,7 +998,7 @@ CARDbAdd_PMKID_Candidate(
 )
 {
PSDevicepDevice = (PSDevice) pDeviceHandler;
-   PPMKID_CANDIDATEpCandidateList;
+   struct PMKID_CANDIDATE *pCandidateList;
unsigned int ii = 0;
 
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO bAdd_PMKID_Candidate START: 
(%d)\n, (int)pDevice-gsPMKIDCandidate.NumCandidates);
diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h
index 45fc8a0..5651e51 100644
--- a/drivers/staging/vt6655/device.h
+++ b/drivers/staging/vt6655/device.h
@@ -227,10 +227,10 @@ typedef enum _NDIS_802_11_STATUS_TYPE
 } NDIS_802_11_STATUS_TYPE, *PNDIS_802_11_STATUS_TYPE;
 
 //Added new types for PMKID Candidate lists.
-typedef struct _PMKID_CANDIDATE {
+struct PMKID_CANDIDATE {
NDIS_802_11_MAC_ADDRESS BSSID;
unsigned long Flags;
-} PMKID_CANDIDATE, *PPMKID_CANDIDATE;
+};
 
 typedef struct _BSSID_INFO
 {
@@ -248,7 +248,7 @@ typedef struct tagSPMKIDCandidateEvent {
NDIS_802_11_STATUS_TYPE StatusType;
unsigned long Version;   // Version of the structure
unsigned long NumCandidates; // No. of pmkid candidates
-   PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
+   struct PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST];
 } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent;
 
 //--
diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c
index 6738478..370ef26 100644
--- a/drivers/staging/vt6655/wmgr.c
+++ b/drivers/staging/vt6655/wmgr.c
@@ -4438,7 +4438,7 @@ bAdd_PMKID_Candidate(
 )
 {
PSDevice pDevice = (PSDevice)hDeviceContext;
-   PPMKID_CANDIDATE pCandidateList;
+   struct PMKID_CANDIDATE *pCandidateList;
unsigned int ii = 0;
 
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO bAdd_PMKID_Candidate START: 
(%d)\n, (int)pDevice-gsPMKIDCandidate.NumCandidates);
-- 
1.7.10.4

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


[PATCH] staging: wlan-ng: fix Missing a blank line after declarations warnings

2014-06-13 Thread Cheng-Wei Lee
Signed-off-by: Quentin Lee lee.rhaps...@gmail.com
---
 drivers/staging/wlan-ng/hfa384x_usb.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c
b/drivers/staging/wlan-ng/hfa384x_usb.c
index 98343ff7..b87cd6b 100644
--- a/drivers/staging/wlan-ng/hfa384x_usb.c
+++ b/drivers/staging/wlan-ng/hfa384x_usb.c
@@ -3533,7 +3533,6 @@ static void hfa384x_usbin_rx(wlandevice_t
*wlandev, struct sk_buff *skb)
}

 done:
-   return;
 }

 /*
@@ -3643,8 +3642,6 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev,

/* pass it back up */
prism2sta_ev_rx(wlandev, skb);
-
-   return;
 }

 /*
@@ -3705,6 +3702,7 @@ static void hfa384x_usbout_callback(struct urb *urb)
case -EPIPE:
{
hfa384x_t *hw = wlandev-priv;
+
netdev_warn(hw-wlandev-netdev,
%s tx pipe stalled: requesting 
reset\n,
wlandev-netdev-name);
-- 
1.7.9.5
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/2 linux-next] coding style clean up for lustre/osc/osc_dev.c

2014-06-13 Thread Real Name
Hi, Greg
 I scaned the git log of linux-next/drivers/staging. It seems all
 patches for coding style clean up had been signed off/picked up by
 you. Could you please sign or reject these patches?

 I worte these patches for task 10 of Eudyptula Challenge.

thanks

On Thu, Jun 12, 2014 at 03:13:37PM +0800, Honggang Li wrote:
 Patches clean up coding style issue of the file:
 linux-next/drivers/staging/lustre/lustre/osc/osc_dev.c
 
 Honggang Li (2):
   lustre/osc/osc_dev.c remove space between sizeof and open parenthesis
   lustre/osc/osc_dev.c add a blank line after declarations
 
  drivers/staging/lustre/lustre/osc/osc_dev.c | 14 --
  1 file changed, 8 insertions(+), 6 deletions(-)
 
 -- 
 1.8.3.1
 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 0/2 linux-next] coding style clean up for lustre/osc/osc_dev.c

2014-06-13 Thread Greg KH
On Fri, Jun 13, 2014 at 10:59:30PM +0800, Real Name wrote:
 Hi, Greg
  I scaned the git log of linux-next/drivers/staging. It seems all
  patches for coding style clean up had been signed off/picked up by
  you. Could you please sign or reject these patches?

You sent these patches:

 On Thu, Jun 12, 2014 at 03:13:37PM +0800, Honggang Li wrote:

Well, I'm guessing it was you, the email address doesn't match up...

Anyway, less than 1 day and you expect a response from a maintainer in
the middle of the kernel merge window?  Hah, that's good.

Please be patient, the earliest I can get to these are after 3.16-rc1 is
released, and even then, it is behind:

$ ~/bin/mdfrm -c ~/mail/todo/
1495 messages in /home/gregkh/mail/todo/

A few patches...

Don't worry, the patch isn't lost, it will be gotten to eventually, in a
few weeks, in time for the next kernel merge window.

thanks,

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


[PATCH] staging: slicoss: Fix coding style issue

2014-06-13 Thread Benedict Boerger
Fix a coding style issue found by checkpatch.pl.
Use ether_addr_copy instead of memcpy.

Done to complete a eudyptula task.

Signed-off-by: Benedict Boerger benedict.boer...@cs.tu-dortmund.de

---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 48841e7..02807a3 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1790,7 +1790,7 @@ static int slic_mcast_add_list(struct adapter *adapter, 
char *address)
if (mcaddr == NULL)
return 1;
 
-   memcpy(mcaddr-address, address, ETH_ALEN);
+   ether_addr_copy(mcaddr-address, address);
 
mcaddr-next = adapter-mcastaddrs;
adapter-mcastaddrs = mcaddr;
-- 
1.9.1

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


Re: [PATCH] staging: slicoss: Fix coding style issue

2014-06-13 Thread Greg KH
On Fri, Jun 13, 2014 at 05:52:33PM +0200, Benedict Boerger wrote:
 Fix a coding style issue found by checkpatch.pl.
 Use ether_addr_copy instead of memcpy.
 
 Done to complete a eudyptula task.
 
 Signed-off-by: Benedict Boerger benedict.boer...@cs.tu-dortmund.de
 
 ---
  drivers/staging/slicoss/slicoss.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/staging/slicoss/slicoss.c 
 b/drivers/staging/slicoss/slicoss.c
 index 48841e7..02807a3 100644
 --- a/drivers/staging/slicoss/slicoss.c
 +++ b/drivers/staging/slicoss/slicoss.c
 @@ -1790,7 +1790,7 @@ static int slic_mcast_add_list(struct adapter *adapter, 
 char *address)
   if (mcaddr == NULL)
   return 1;
  
 - memcpy(mcaddr-address, address, ETH_ALEN);
 + ether_addr_copy(mcaddr-address, address);
  
   mcaddr-next = adapter-mcastaddrs;
   adapter-mcastaddrs = mcaddr;

Are you sure this is correct?  It's not always a one-to-one replacement
from what I have been told.

thanks,

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


Re: [PATCH] staging: wlan-ng: fix Missing a blank line after declarations warnings

2014-06-13 Thread Greg Kroah-Hartman
On Fri, Jun 13, 2014 at 10:58:14PM +0800, Cheng-Wei Lee wrote:
 Signed-off-by: Quentin Lee lee.rhaps...@gmail.com
 ---
  drivers/staging/wlan-ng/hfa384x_usb.c |4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
 
 diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c
 b/drivers/staging/wlan-ng/hfa384x_usb.c
 index 98343ff7..b87cd6b 100644
 --- a/drivers/staging/wlan-ng/hfa384x_usb.c
 +++ b/drivers/staging/wlan-ng/hfa384x_usb.c
 @@ -3533,7 +3533,6 @@ static void hfa384x_usbin_rx(wlandevice_t
 *wlandev, struct sk_buff *skb)
   }
 
  done:
 - return;
  }

That's a good thing to do, but it is not what you said you did up above
in the changelog entry.

Please make up 2 patches here, one to remove the unneeded return; lines,
and one to fix up the whitespace of variables.

thanks,

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


Re: [PATCH] staging: wlan-ng: fix Missing a blank line after declarations warnings

2014-06-13 Thread Joe Perches
On Fri, 2014-06-13 at 10:15 -0700, Greg Kroah-Hartman wrote:
 On Fri, Jun 13, 2014 at 10:58:14PM +0800, Cheng-Wei Lee wrote:
  Signed-off-by: Quentin Lee lee.rhaps...@gmail.com
[]
  diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c
[]
  @@ -3533,7 +3533,6 @@ static void hfa384x_usbin_rx(wlandevice_t
  *wlandev, struct sk_buff *skb)
  }
  
   done:
  -   return;
   }
 
 That's a good thing to do, but it is not what you said you did up above
 in the changelog entry.

I don't believe it's a good thing to do at all.
I suspect more that this wasn't compile tested.

This doesn't compile for at least several
supported gcc versions. 

gcc doesn't (didn't? I haven't tried 4.9) like:

label:
}

to terminate a function definition.

$ cat label_test.c
void func(void)
{
goto label;
label:
}
$

with gcc 4.8:

$ gcc label_test.c
label_test.c: In function ‘func’:
label_test.c:5:1: error: label at end of compound statement
 label:
 ^

whereas this compiles fine:

$ cat label_test2.c
void func(void)
{
goto label;
label:
;
}
$

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


[PATCH 2/2] staging: tidspbridge: Fix function pointer spacing in struct definition

2014-06-13 Thread Jeff Oczek
Simple coding style changes
This is for the Eudyptula Challenge task 10

Signed-off-by: Jeff Oczek jeffoc...@gmail.com
---
 drivers/staging/tidspbridge/include/dspbridge/dblldefs.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h 
b/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
index 5e44ba6..dd3e6eb 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
@@ -168,11 +168,11 @@ struct dbll_attrs {
 *  These file manipulation functions should be compatible with the
 *  C run time library functions of the same name.
 */
-s32(*fread) (void *, size_t, size_t, void *);
-s32(*fseek) (void *, long, int);
-s32(*ftell) (void *);
-s32(*fclose) (void *);
-   void *(*fopen) (const char *, const char *);
+s32 (*fread)(void *, size_t, size_t, void *);
+s32 (*fseek)(void *, long, int);
+s32 (*ftell)(void *);
+s32 (*fclose)(void *);
+   void *(*fopen)(const char *, const char *);
 };
 
 /*
-- 
1.9.1

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


[PATCH 1/2] staging: tidspbridge: Fix pointer spacing

2014-06-13 Thread Jeff Oczek
Simple coding style changes
This is for Eudyptula Challenge task 10

Signed-off-by: Jeff Oczek jeffoc...@gmail.com
---
 drivers/staging/tidspbridge/include/dspbridge/dblldefs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h 
b/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
index 30e0aa0..5e44ba6 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
@@ -130,7 +130,7 @@ typedef s32(*dbll_seek_fxn) (void *, long, int);
  *  FALSE:  Failed to find symbol.
  */
 typedef bool(*dbll_sym_lookup) (void *handle, void *parg, void *rmm_handle,
-   const char *name, struct dbll_sym_val ** sym);
+   const char *name, struct dbll_sym_val **sym);
 
 /*
  *   dbll_tell_fxn 
@@ -309,7 +309,7 @@ typedef bool(*dbll_get_c_addr_fxn) (struct dbll_library_obj 
*lib, char *name,
  *  Ensures:
  */
 typedef int(*dbll_get_sect_fxn) (struct dbll_library_obj *lib,
-   char *name, u32 * addr, u32 * size);
+   char *name, u32 *addr, u32 *size);
 
 /*
  *   dbll_init 
-- 
1.9.1

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


Re: [PATCH 2/2] staging: tidspbridge: Fix function pointer spacing in struct definition

2014-06-13 Thread Joe Perches
On Fri, 2014-06-13 at 22:48 -0400, Jeff Oczek wrote:
 Simple coding style changes
[]
 diff --git a/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h 
 b/drivers/staging/tidspbridge/include/dspbridge/dblldefs.h
[]
 @@ -168,11 +168,11 @@ struct dbll_attrs {
[]
 -  s32(*fread) (void *, size_t, size_t, void *);
 -  s32(*fseek) (void *, long, int);
 -  s32(*ftell) (void *);
 -  s32(*fclose) (void *);
 - void *(*fopen) (const char *, const char *);
 +  s32 (*fread)(void *, size_t, size_t, void *);
 +  s32 (*fseek)(void *, long, int);
 +  s32 (*ftell)(void *);
 +  s32 (*fclose)(void *);
 + void *(*fopen)(const char *, const char *);
  };

Better would be to describe the arguments with
variable names and align all the return values

void *(*fopen

s32 (*fread)(void *arg1, size_t val1, size_t val2, void *ptr1);
s32 (*fseek)(void *ptr1, long arg2, int arg3);
s32 (*ftell)(void * ptr);
s32 (*fclose)(void *ptr);
void *(*fopen)(const char *ptr1, const char *ptr2);

where arg, val, ptr are actually useful descriptors

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


[PATCH] staging: ced1401: fix sparse warning for ced1401

2014-06-13 Thread Seunghun Lee
This patch fixes below warning.

drivers/staging/ced1401/ced_ioc.c:703:30: warning: incorrect type in assignment 
(different address spaces)
drivers/staging/ced1401/ced_ioc.c:703:30:expected void *[usertype] 
lpvBuff
drivers/staging/ced1401/ced_ioc.c:703:30:got char [noderef] 
asn:1*puBuf

Signed-off-by: Seunghun Lee way...@gmail.com
---
 drivers/staging/ced1401/ced_ioc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/ced1401/ced_ioc.c 
b/drivers/staging/ced1401/ced_ioc.c
index ebbc509..963b941 100644
--- a/drivers/staging/ced1401/ced_ioc.c
+++ b/drivers/staging/ced1401/ced_ioc.c
@@ -700,7 +700,7 @@ static int SetArea(DEVICE_EXTENSION *pdx, int nArea, char 
__user *puBuf,
/*  kmap() or kmap_atomic() to get a virtual address. 
page_address will give you */
/*  (null) or at least it does in this context with an x86 
machine. */
spin_lock_irq(pdx-stagedLock);
-   pTA-lpvBuff = puBuf;   /*  keep start of region (user address) 
*/
+   pTA-lpvBuff = (__force void *)puBuf;   /*  keep start of 
region (user address) */
pTA-dwBaseOffset = ulOffset;   /*  save offset in first page 
to start of xfer */
pTA-dwLength = dwLength;   /*  Size if the region in bytes 
*/
pTA-pPages = pPages;   /*  list of pages that are used by 
buffer */
-- 
1.7.9.5

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