All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] staging: dgnc: cleanup of the dgnc_driver.c
@ 2014-08-06 12:21 Konrad Zapalowicz
  2014-08-06 12:21 ` [PATCH 1/7] staging: dgnc: Fix externs should be avoided in the .c files Konrad Zapalowicz
  2014-08-12  6:08 ` [PATCH v2 1/7] staging: dgnc: Fix externs should be avoided in the .c files Konrad Zapalowicz
  0 siblings, 2 replies; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: markh, gregkh, driverdev-devel, devel, Konrad Zapalowicz

This series of patches cleans up a bit the dgnc code. The focus is
mostly put on the dgnc_driver.c file however the sparse warning from
the other file has been fixed too.

There is no functional changes, only the sparse warnings have been
fixed, some of the checkpath issues have been fixed too (except on
line over 80 chars warnings).

Because the TODO file for this driver was not valid the bullet list in
it has been updated with the current status. The update is based on 
what I have found in the driver devel mailing list archives for this
driver.

Konrad Zapalowicz (7):
  staging: dgnc: Fix externs should be avoided in the .c files
  staging: dgnc: Fix no spaces before tabs checkpath warning
  staging: dgnc: Fix frame size is larger than 1024B
  staging: dgnc: Remove unnecessary functions from dgnc_driver.c
  staging: dgnc: Move utility functions out of dgnc_driver.c
  staging: dgnc: Siplify the dgnc_start function
  staging: dgnc: Update the TODO file

 drivers/staging/dgnc/Makefile      |   3 +-
 drivers/staging/dgnc/TODO          |   5 -
 drivers/staging/dgnc/dgnc_driver.c | 287 ++++++++++++-------------------------
 drivers/staging/dgnc/dgnc_driver.h |  10 --
 drivers/staging/dgnc/dgnc_tty.c    |  17 ++-
 drivers/staging/dgnc/dgnc_utils.c  |  70 +++++++++
 drivers/staging/dgnc/dgnc_utils.h  |   7 +
 7 files changed, 182 insertions(+), 217 deletions(-)
 create mode 100644 drivers/staging/dgnc/dgnc_utils.c
 create mode 100644 drivers/staging/dgnc/dgnc_utils.h

-- 
1.8.1.2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/7] staging: dgnc: Fix externs should be avoided in the .c files
  2014-08-06 12:21 [PATCH 0/7] staging: dgnc: cleanup of the dgnc_driver.c Konrad Zapalowicz
@ 2014-08-06 12:21 ` Konrad Zapalowicz
  2014-08-06 12:21   ` [PATCH 2/7] staging: dgnc: Fix no spaces before tabs checkpath warning Konrad Zapalowicz
  2014-08-12  6:08 ` [PATCH v2 1/7] staging: dgnc: Fix externs should be avoided in the .c files Konrad Zapalowicz
  1 sibling, 1 reply; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

This commit fixes the following checkpatch warnings:

WARNING: externs should be avoided in .c files
    #80: FILE: drivers/staging/dgnc/dgnc_driver.c:80:
        +int            dgnc_init_module(void);
    #81: FILE: drivers/staging/dgnc/dgnc_driver.c:81:
        +void           dgnc_cleanup_module(void);

This was caused by putting the declarations for module init and module
exit fucntions on the top of the file. The fix removes these
declarations plus it also corrects the type of the init/exit functions.

Due to the dependency between init and exit functions the
dgnc_cleanup_module had to be put first.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 84 ++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 764613b..1789cf3 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -76,12 +76,6 @@ static void		dgnc_remove_one(struct pci_dev *dev);
 static int		dgnc_probe1(struct pci_dev *pdev, int card_type);
 static void		dgnc_do_remap(struct dgnc_board *brd);
 
-/* Driver load/unload functions */
-int		dgnc_init_module(void);
-void		dgnc_cleanup_module(void);
-
-module_init(dgnc_init_module);
-module_exit(dgnc_cleanup_module);
 
 
 /*
@@ -199,13 +193,49 @@ char *dgnc_driver_state_text[] = {
  *
  ************************************************************************/
 
+/*
+ * dgnc_cleanup_module()
+ *
+ * Module unload.  This is where it all ends.
+ */
+static void __exit dgnc_cleanup_module(void)
+{
+	int i;
+	ulong lock_flags;
+
+	DGNC_LOCK(dgnc_poll_lock, lock_flags);
+	dgnc_poll_stop = 1;
+	DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
+
+	/* Turn off poller right away. */
+	del_timer_sync(&dgnc_poll_timer);
+
+	dgnc_remove_driver_sysfiles(&dgnc_driver);
+
+	if (dgnc_Major_Control_Registered) {
+		device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+		class_destroy(dgnc_class);
+		unregister_chrdev(dgnc_Major, "dgnc");
+	}
+
+	for (i = 0; i < dgnc_NumBoards; ++i) {
+		dgnc_remove_ports_sysfiles(dgnc_Board[i]);
+		dgnc_tty_uninit(dgnc_Board[i]);
+		dgnc_cleanup_board(dgnc_Board[i]);
+	}
+
+	dgnc_tty_post_uninit();
+
+	if (dgnc_NumBoards)
+		pci_unregister_driver(&dgnc_driver);
+}
 
 /*
  * init_module()
  *
  * Module load.  This is where it all starts.
  */
-int dgnc_init_module(void)
+static int __init dgnc_init_module(void)
 {
 	int rc = 0;
 
@@ -243,6 +273,8 @@ int dgnc_init_module(void)
 	return rc;
 }
 
+module_init(dgnc_init_module);
+module_exit(dgnc_cleanup_module);
 
 /*
  * Start of driver.
@@ -355,44 +387,6 @@ static void dgnc_remove_one(struct pci_dev *dev)
 }
 
 /*
- * dgnc_cleanup_module()
- *
- * Module unload.  This is where it all ends.
- */
-void dgnc_cleanup_module(void)
-{
-	int i;
-	ulong lock_flags;
-
-	DGNC_LOCK(dgnc_poll_lock, lock_flags);
-	dgnc_poll_stop = 1;
-	DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
-
-	/* Turn off poller right away. */
-	del_timer_sync(&dgnc_poll_timer);
-
-	dgnc_remove_driver_sysfiles(&dgnc_driver);
-
-	if (dgnc_Major_Control_Registered) {
-		device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
-		class_destroy(dgnc_class);
-		unregister_chrdev(dgnc_Major, "dgnc");
-	}
-
-	for (i = 0; i < dgnc_NumBoards; ++i) {
-		dgnc_remove_ports_sysfiles(dgnc_Board[i]);
-		dgnc_tty_uninit(dgnc_Board[i]);
-		dgnc_cleanup_board(dgnc_Board[i]);
-	}
-
-	dgnc_tty_post_uninit();
-
-	if (dgnc_NumBoards)
-		pci_unregister_driver(&dgnc_driver);
-}
-
-
-/*
  * dgnc_cleanup_board()
  *
  * Free all the memory associated with a board
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/7] staging: dgnc: Fix no spaces before tabs checkpath warning
  2014-08-06 12:21 ` [PATCH 1/7] staging: dgnc: Fix externs should be avoided in the .c files Konrad Zapalowicz
@ 2014-08-06 12:21   ` Konrad Zapalowicz
  2014-08-06 12:21     ` [PATCH 3/7] staging: dgnc: Fix frame size is larger than 1024B Konrad Zapalowicz
  0 siblings, 1 reply; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

This commit corrects the 'no space before tabs' checkpath warning.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 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 1789cf3..991ea57 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -57,7 +57,7 @@ MODULE_SUPPORTED_DEVICE("dgnc");
  */
 PARM_INT(debug,		0x00,		0644,	"Driver debugging level");
 PARM_INT(rawreadok,	1,		0644,	"Bypass flip buffers on input");
-PARM_INT(trcbuf_size,	0x100000,	0644, 	"Debugging trace buffer size.");
+PARM_INT(trcbuf_size,	0x100000,	0644,	"Debugging trace buffer size.");
 
 /**************************************************************************
  *
@@ -83,7 +83,7 @@ static void		dgnc_do_remap(struct dgnc_board *brd);
  */
 static const struct file_operations dgnc_BoardFops = {
 	.owner		=	THIS_MODULE,
-	.unlocked_ioctl =  	dgnc_mgmt_ioctl,
+	.unlocked_ioctl =	dgnc_mgmt_ioctl,
 	.open		=	dgnc_mgmt_open,
 	.release	=	dgnc_mgmt_close
 };
@@ -111,7 +111,7 @@ static struct class *dgnc_class;
 /*
  * Poller stuff
  */
-static 			DEFINE_SPINLOCK(dgnc_poll_lock);	/* Poll scheduling lock */
+static DEFINE_SPINLOCK(dgnc_poll_lock); /* Poll scheduling lock */
 static ulong		dgnc_poll_time;				/* Time of next poll */
 static uint		dgnc_poll_stop;				/* Used to tell poller to stop */
 static struct timer_list dgnc_poll_timer;
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/7] staging: dgnc: Fix frame size is larger than 1024B
  2014-08-06 12:21   ` [PATCH 2/7] staging: dgnc: Fix no spaces before tabs checkpath warning Konrad Zapalowicz
@ 2014-08-06 12:21     ` Konrad Zapalowicz
  2014-08-06 12:21       ` [PATCH 4/7] staging: dgnc: Remove unnecessary functions from dgnc_driver.c Konrad Zapalowicz
  0 siblings, 1 reply; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: markh, gregkh, driverdev-devel, devel, Konrad Zapalowicz

This comit fixes the following sparse warnign:

drivers/staging/dgnc/dgnc_tty.c:572:1:
    warning: the frame size of 1060 bytes is larger than 1024 bytes
    [-Wframe-larger-than=]

This was caused by having buffer as an automatic variable. This commit
moves it from the stack to the heap.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/dgnc_tty.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index c712b43..2dc78f7 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -471,13 +471,18 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int
 	int nbuf;
 	int i;
 	int tmpbuflen;
-	char tmpbuf[TMPBUFLEN];
-	char *p = tmpbuf;
+	char *tmpbuf;
+	char *p;
 	int too_much_data;
 
+	tmpbuf = kzalloc(TMPBUFLEN, GFP_KERNEL);
+	if (!tmpbuf)
+		return;
+	p = tmpbuf;
+
 	/* Leave if sniff not open */
 	if (!(ch->ch_sniff_flags & SNIFF_OPEN))
-		return;
+		goto exit;
 
 	do_gettimeofday(&tv);
 
@@ -524,7 +529,7 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int
 			 * function was probably called by the interrupt/timer routines!
 			 */
 			if (n == 0)
-				return;
+				goto exit;
 
 			/*
 			 * Copy as much data as will fit.
@@ -569,6 +574,9 @@ void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int
 		}
 
 	} while (too_much_data);
+
+exit:
+	kfree(tmpbuf);
 }
 
 
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/7] staging: dgnc: Remove unnecessary functions from dgnc_driver.c
  2014-08-06 12:21     ` [PATCH 3/7] staging: dgnc: Fix frame size is larger than 1024B Konrad Zapalowicz
@ 2014-08-06 12:21       ` Konrad Zapalowicz
  2014-08-06 12:21         ` [PATCH 5/7] staging: dgnc: Move utility functions out of dgnc_driver.c Konrad Zapalowicz
  0 siblings, 1 reply; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

This commit slightly cleans up the dgnc_driver.c file. The changes
include removing one-line proxy functions as they were not needed.
Additionaly the pci 'remove' function is deleted because it was no
need for it.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 30 ++----------------------------
 1 file changed, 2 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 991ea57..a92f617 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -70,14 +70,9 @@ static void		dgnc_init_globals(void);
 static int		dgnc_found_board(struct pci_dev *pdev, int id);
 static void		dgnc_cleanup_board(struct dgnc_board *brd);
 static void		dgnc_poll_handler(ulong dummy);
-static int		dgnc_init_pci(void);
 static int		dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
-static void		dgnc_remove_one(struct pci_dev *dev);
-static int		dgnc_probe1(struct pci_dev *pdev, int card_type);
 static void		dgnc_do_remap(struct dgnc_board *brd);
 
-
-
 /*
  * File operations permitted on Control/Management major.
  */
@@ -170,7 +165,6 @@ static struct pci_driver dgnc_driver = {
 	.name		= "dgnc",
 	.probe		= dgnc_init_one,
 	.id_table       = dgnc_pci_tbl,
-	.remove		= dgnc_remove_one,
 };
 
 
@@ -252,7 +246,7 @@ static int __init dgnc_init_module(void)
 	/*
 	 * Find and configure all the cards
 	 */
-	rc = dgnc_init_pci();
+	rc = pci_register_driver(&dgnc_driver);
 
 	/*
 	 * If something went wrong in the scan, bail out of driver.
@@ -346,15 +340,6 @@ static int dgnc_start(void)
 	return rc;
 }
 
-/*
- * Register pci driver, and return how many boards we have.
- */
-static int dgnc_init_pci(void)
-{
-	return pci_register_driver(&dgnc_driver);
-}
-
-
 /* returns count (>= 0), or negative on error */
 static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
@@ -366,7 +351,7 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (rc < 0) {
 		rc = -EIO;
 	} else {
-		rc = dgnc_probe1(pdev, ent->driver_data);
+		rc = dgnc_found_board(pdev, ent->driver_data);
 		if (rc == 0) {
 			dgnc_NumBoards++;
 			DPR_INIT(("Incrementing numboards to %d\n", dgnc_NumBoards));
@@ -375,17 +360,6 @@ static int dgnc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	return rc;
 }
 
-static int dgnc_probe1(struct pci_dev *pdev, int card_type)
-{
-	return dgnc_found_board(pdev, card_type);
-}
-
-
-static void dgnc_remove_one(struct pci_dev *dev)
-{
-	/* Do Nothing */
-}
-
 /*
  * dgnc_cleanup_board()
  *
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 5/7] staging: dgnc: Move utility functions out of dgnc_driver.c
  2014-08-06 12:21       ` [PATCH 4/7] staging: dgnc: Remove unnecessary functions from dgnc_driver.c Konrad Zapalowicz
@ 2014-08-06 12:21         ` Konrad Zapalowicz
  2014-08-06 12:21           ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Konrad Zapalowicz
  0 siblings, 1 reply; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

This commit moves the utility functions out of dgnc_driver.c file and
puts them in the new dgnc_utils.{c,h} files. The accompanying changes
adjust the existing code to work with this design.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/Makefile      |  3 +-
 drivers/staging/dgnc/dgnc_driver.c | 74 --------------------------------------
 drivers/staging/dgnc/dgnc_driver.h | 10 ------
 drivers/staging/dgnc/dgnc_tty.c    |  1 +
 drivers/staging/dgnc/dgnc_utils.c  | 70 ++++++++++++++++++++++++++++++++++++
 drivers/staging/dgnc/dgnc_utils.h  |  7 ++++
 6 files changed, 80 insertions(+), 85 deletions(-)
 create mode 100644 drivers/staging/dgnc/dgnc_utils.c
 create mode 100644 drivers/staging/dgnc/dgnc_utils.h

diff --git a/drivers/staging/dgnc/Makefile b/drivers/staging/dgnc/Makefile
index 733434f..b69f7b6 100644
--- a/drivers/staging/dgnc/Makefile
+++ b/drivers/staging/dgnc/Makefile
@@ -4,4 +4,5 @@ obj-$(CONFIG_DGNC) += dgnc.o
 
 dgnc-objs :=   dgnc_cls.o dgnc_driver.o\
                dgnc_mgmt.o dgnc_neo.o\
-               dgnc_tty.o dgnc_sysfs.o
+               dgnc_tty.o dgnc_sysfs.o\
+	       dgnc_utils.o
diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index a92f617..da7b226 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -821,77 +821,3 @@ static void dgnc_init_globals(void)
 	init_timer(&dgnc_poll_timer);
 }
 
-
-/************************************************************************
- *
- * Utility functions
- *
- ************************************************************************/
-
-/*
- * dgnc_ms_sleep()
- *
- * Put the driver to sleep for x ms's
- *
- * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal.
- */
-int dgnc_ms_sleep(ulong ms)
-{
-	current->state = TASK_INTERRUPTIBLE;
-	schedule_timeout((ms * HZ) / 1000);
-	return signal_pending(current);
-}
-
-
-
-/*
- *      dgnc_ioctl_name() : Returns a text version of each ioctl value.
- */
-char *dgnc_ioctl_name(int cmd)
-{
-	switch (cmd) {
-
-	case TCGETA:		return "TCGETA";
-	case TCGETS:		return "TCGETS";
-	case TCSETA:		return "TCSETA";
-	case TCSETS:		return "TCSETS";
-	case TCSETAW:		return "TCSETAW";
-	case TCSETSW:		return "TCSETSW";
-	case TCSETAF:		return "TCSETAF";
-	case TCSETSF:		return "TCSETSF";
-	case TCSBRK:		return "TCSBRK";
-	case TCXONC:		return "TCXONC";
-	case TCFLSH:		return "TCFLSH";
-	case TIOCGSID:		return "TIOCGSID";
-
-	case TIOCGETD:		return "TIOCGETD";
-	case TIOCSETD:		return "TIOCSETD";
-	case TIOCGWINSZ:	return "TIOCGWINSZ";
-	case TIOCSWINSZ:	return "TIOCSWINSZ";
-
-	case TIOCMGET:		return "TIOCMGET";
-	case TIOCMSET:		return "TIOCMSET";
-	case TIOCMBIS:		return "TIOCMBIS";
-	case TIOCMBIC:		return "TIOCMBIC";
-
-	/* from digi.h */
-	case DIGI_SETA:		return "DIGI_SETA";
-	case DIGI_SETAW:	return "DIGI_SETAW";
-	case DIGI_SETAF:	return "DIGI_SETAF";
-	case DIGI_SETFLOW:	return "DIGI_SETFLOW";
-	case DIGI_SETAFLOW:	return "DIGI_SETAFLOW";
-	case DIGI_GETFLOW:	return "DIGI_GETFLOW";
-	case DIGI_GETAFLOW:	return "DIGI_GETAFLOW";
-	case DIGI_GETA:		return "DIGI_GETA";
-	case DIGI_GEDELAY:	return "DIGI_GEDELAY";
-	case DIGI_SEDELAY:	return "DIGI_SEDELAY";
-	case DIGI_GETCUSTOMBAUD: return "DIGI_GETCUSTOMBAUD";
-	case DIGI_SETCUSTOMBAUD: return "DIGI_SETCUSTOMBAUD";
-	case TIOCMODG:		return "TIOCMODG";
-	case TIOCMODS:		return "TIOCMODS";
-	case TIOCSDTR:		return "TIOCSDTR";
-	case TIOCCDTR:		return "TIOCCDTR";
-
-	default:		return "unknown";
-	}
-}
diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h
index 58b5aa7..eae0494 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -481,16 +481,6 @@ struct channel_t {
 	wait_queue_head_t ch_sniff_wait;
 };
 
-
-/*************************************************************************
- *
- * Prototypes for non-static functions used in more than one module
- *
- *************************************************************************/
-
-extern int		dgnc_ms_sleep(ulong ms);
-extern char		*dgnc_ioctl_name(int cmd);
-
 /*
  * Our Global Variables.
  */
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 2dc78f7..281491a 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -57,6 +57,7 @@
 #include "dgnc_cls.h"
 #include "dpacompat.h"
 #include "dgnc_sysfs.h"
+#include "dgnc_utils.h"
 
 #define init_MUTEX(sem)	 sema_init(sem, 1)
 #define DECLARE_MUTEX(name)     \
diff --git a/drivers/staging/dgnc/dgnc_utils.c b/drivers/staging/dgnc/dgnc_utils.c
new file mode 100644
index 0000000..61efc13
--- /dev/null
+++ b/drivers/staging/dgnc/dgnc_utils.c
@@ -0,0 +1,70 @@
+#include <linux/tty.h>
+#include <linux/sched.h>
+#include "dgnc_utils.h"
+#include "digi.h"
+
+/*
+ * dgnc_ms_sleep()
+ *
+ * Put the driver to sleep for x ms's
+ *
+ * Returns 0 if timed out, !0 (showing signal) if interrupted by a signal.
+ */
+int dgnc_ms_sleep(ulong ms)
+{
+	current->state = TASK_INTERRUPTIBLE;
+	schedule_timeout((ms * HZ) / 1000);
+	return signal_pending(current);
+}
+
+/*
+ *      dgnc_ioctl_name() : Returns a text version of each ioctl value.
+ */
+char *dgnc_ioctl_name(int cmd)
+{
+	switch (cmd) {
+
+	case TCGETA:		return "TCGETA";
+	case TCGETS:		return "TCGETS";
+	case TCSETA:		return "TCSETA";
+	case TCSETS:		return "TCSETS";
+	case TCSETAW:		return "TCSETAW";
+	case TCSETSW:		return "TCSETSW";
+	case TCSETAF:		return "TCSETAF";
+	case TCSETSF:		return "TCSETSF";
+	case TCSBRK:		return "TCSBRK";
+	case TCXONC:		return "TCXONC";
+	case TCFLSH:		return "TCFLSH";
+	case TIOCGSID:		return "TIOCGSID";
+
+	case TIOCGETD:		return "TIOCGETD";
+	case TIOCSETD:		return "TIOCSETD";
+	case TIOCGWINSZ:	return "TIOCGWINSZ";
+	case TIOCSWINSZ:	return "TIOCSWINSZ";
+
+	case TIOCMGET:		return "TIOCMGET";
+	case TIOCMSET:		return "TIOCMSET";
+	case TIOCMBIS:		return "TIOCMBIS";
+	case TIOCMBIC:		return "TIOCMBIC";
+
+	/* from digi.h */
+	case DIGI_SETA:		return "DIGI_SETA";
+	case DIGI_SETAW:	return "DIGI_SETAW";
+	case DIGI_SETAF:	return "DIGI_SETAF";
+	case DIGI_SETFLOW:	return "DIGI_SETFLOW";
+	case DIGI_SETAFLOW:	return "DIGI_SETAFLOW";
+	case DIGI_GETFLOW:	return "DIGI_GETFLOW";
+	case DIGI_GETAFLOW:	return "DIGI_GETAFLOW";
+	case DIGI_GETA:		return "DIGI_GETA";
+	case DIGI_GEDELAY:	return "DIGI_GEDELAY";
+	case DIGI_SEDELAY:	return "DIGI_SEDELAY";
+	case DIGI_GETCUSTOMBAUD: return "DIGI_GETCUSTOMBAUD";
+	case DIGI_SETCUSTOMBAUD: return "DIGI_SETCUSTOMBAUD";
+	case TIOCMODG:		return "TIOCMODG";
+	case TIOCMODS:		return "TIOCMODS";
+	case TIOCSDTR:		return "TIOCSDTR";
+	case TIOCCDTR:		return "TIOCCDTR";
+
+	default:		return "unknown";
+	}
+}
diff --git a/drivers/staging/dgnc/dgnc_utils.h b/drivers/staging/dgnc/dgnc_utils.h
new file mode 100644
index 0000000..cebf601
--- /dev/null
+++ b/drivers/staging/dgnc/dgnc_utils.h
@@ -0,0 +1,7 @@
+#ifndef __DGNC_UTILS_H
+#define __DGNC_UTILS_H
+
+int dgnc_ms_sleep(ulong ms);
+char *dgnc_ioctl_name(int cmd);
+
+#endif
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function
  2014-08-06 12:21         ` [PATCH 5/7] staging: dgnc: Move utility functions out of dgnc_driver.c Konrad Zapalowicz
@ 2014-08-06 12:21           ` Konrad Zapalowicz
  2014-08-06 12:21             ` [PATCH 7/7] staging: dgnc: Update the TODO file Konrad Zapalowicz
  2014-08-06 12:31             ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Dan Carpenter
  0 siblings, 2 replies; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

This commit slightly simplifies the sgnc_start() function by
rearranging it. As a result the indentation level is reduced.
This is not the functional change.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 93 +++++++++++++++++++-------------------
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index da7b226..66f2b2d 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -278,65 +278,63 @@ static int dgnc_start(void)
 	int rc = 0;
 	unsigned long flags;
 
-	if (dgnc_driver_start == FALSE) {
+	if (unlikely(dgnc_driver_start == TRUE))
+		goto exit;
+	dgnc_driver_start = TRUE;
 
-		dgnc_driver_start = TRUE;
+	/* make sure that the globals are init'd before we do anything else */
+	dgnc_init_globals();
 
-		/* make sure that the globals are init'd before we do anything else */
-		dgnc_init_globals();
-
-		dgnc_NumBoards = 0;
-
-		APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
+	APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
 
+	/*
+	 * 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.
+	 */
+	if (!dgnc_Major_Control_Registered) {
 		/*
-		 * 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
 		 */
-		if (!dgnc_Major_Control_Registered) {
-			/*
-			 * Register management/dpa devices
-			 */
-			rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
-			if (rc <= 0) {
-				APR(("Can't register dgnc driver device (%d)\n", rc));
-				rc = -ENXIO;
-				return rc;
-			}
-			dgnc_Major = rc;
-
-			dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
-			device_create(dgnc_class, NULL,
-				MKDEV(dgnc_Major, 0),
-				NULL, "dgnc_mgmt");
-			dgnc_Major_Control_Registered = TRUE;
+		rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
+		if (rc <= 0) {
+			APR(("Can't register dgnc driver device (%d)\n", rc));
+			rc = -ENXIO;
+			goto exit;
 		}
+		dgnc_Major = rc;
 
-		/*
-		 * Init any global tty stuff.
-		 */
-		rc = dgnc_tty_preinit();
+		dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
+		device_create(dgnc_class, NULL,
+			MKDEV(dgnc_Major, 0),
+			NULL, "dgnc_mgmt");
+		dgnc_Major_Control_Registered = TRUE;
+	}
 
-		if (rc < 0) {
-			APR(("tty preinit - not enough memory (%d)\n", rc));
-			return rc;
-		}
+	/*
+	 * Init any global tty stuff.
+	 */
+	rc = dgnc_tty_preinit();
 
-		/* Start the poller */
-		DGNC_LOCK(dgnc_poll_lock, flags);
-		init_timer(&dgnc_poll_timer);
-		dgnc_poll_timer.function = dgnc_poll_handler;
-		dgnc_poll_timer.data = 0;
-		dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
-		dgnc_poll_timer.expires = dgnc_poll_time;
-		DGNC_UNLOCK(dgnc_poll_lock, flags);
+	if (rc < 0) {
+		APR(("tty preinit - not enough memory (%d)\n", rc));
+		goto exit;
+	}
 
-		add_timer(&dgnc_poll_timer);
+	/* Start the poller */
+	DGNC_LOCK(dgnc_poll_lock, flags);
+	init_timer(&dgnc_poll_timer);
+	dgnc_poll_timer.function = dgnc_poll_handler;
+	dgnc_poll_timer.data = 0;
+	dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
+	dgnc_poll_timer.expires = dgnc_poll_time;
+	DGNC_UNLOCK(dgnc_poll_lock, flags);
 
-		dgnc_driver_state = DRIVER_READY;
-	}
+	add_timer(&dgnc_poll_timer);
+
+	dgnc_driver_state = DRIVER_READY;
 
+exit:
 	return rc;
 }
 
@@ -814,6 +812,7 @@ static void dgnc_init_globals(void)
 	dgnc_rawreadok		= rawreadok;
 	dgnc_trcbuf_size	= trcbuf_size;
 	dgnc_debug		= debug;
+	dgnc_NumBoards		= 0;
 
 	for (i = 0; i < MAXBOARDS; i++)
 		dgnc_Board[i] = NULL;
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 7/7] staging: dgnc: Update the TODO file
  2014-08-06 12:21           ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Konrad Zapalowicz
@ 2014-08-06 12:21             ` Konrad Zapalowicz
  2014-08-06 12:31             ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Dan Carpenter
  1 sibling, 0 replies; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 12:21 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

It turned out that the TODO file contained the invalid information as
some of the work has already been done. This commit updates it with the
current status of what is left to be done.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/TODO | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/staging/dgnc/TODO b/drivers/staging/dgnc/TODO
index 1ff2d18..d2828c7 100644
--- a/drivers/staging/dgnc/TODO
+++ b/drivers/staging/dgnc/TODO
@@ -1,9 +1,4 @@
-* remove kzalloc casts
 * checkpatch fixes
-* sparse fixes
-* fix use of sizeof(). Example replace sizeof(struct board_t) 
-  with sizeof(*brd) and remove sizeof(char)
-* change name of board_t to dgnc_board
 * split two assignments into the two assignments on two lines;
   don't use two equals signs
 * remove unecessary comments
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function
  2014-08-06 12:21           ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Konrad Zapalowicz
  2014-08-06 12:21             ` [PATCH 7/7] staging: dgnc: Update the TODO file Konrad Zapalowicz
@ 2014-08-06 12:31             ` Dan Carpenter
  2014-08-06 13:22               ` [PATCH v2 " Konrad Zapalowicz
  2014-08-06 13:40               ` [PATCH 6/7 v3] " Konrad Zapalowicz
  1 sibling, 2 replies; 14+ messages in thread
From: Dan Carpenter @ 2014-08-06 12:31 UTC (permalink / raw)
  To: Konrad Zapalowicz; +Cc: devel, lidza.louina, driverdev-devel, gregkh

On Wed, Aug 06, 2014 at 02:21:24PM +0200, Konrad Zapalowicz wrote:
> diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
> index da7b226..66f2b2d 100644
> --- a/drivers/staging/dgnc/dgnc_driver.c
> +++ b/drivers/staging/dgnc/dgnc_driver.c
> @@ -278,65 +278,63 @@ static int dgnc_start(void)
>  	int rc = 0;
>  	unsigned long flags;
>  
> -	if (dgnc_driver_start == FALSE) {
> +	if (unlikely(dgnc_driver_start == TRUE))
> +		goto exit;

Don't add unlikely() in driver code.  Just return directly here.

regards,
dan carpenter

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 6/7] staging: dgnc: Siplify the dgnc_start function
  2014-08-06 12:31             ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Dan Carpenter
@ 2014-08-06 13:22               ` Konrad Zapalowicz
  2014-08-06 13:31                 ` Dan Carpenter
  2014-08-06 13:40               ` [PATCH 6/7 v3] " Konrad Zapalowicz
  1 sibling, 1 reply; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 13:22 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

This commit slightly simplifies the sgnc_start() function by
rearranging it. As a result the indentation level is reduced.
This is not the functional change.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 93 +++++++++++++++++++-------------------
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index da7b226..8efbdc9c 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -278,65 +278,63 @@ static int dgnc_start(void)
 	int rc = 0;
 	unsigned long flags;
 
-	if (dgnc_driver_start == FALSE) {
-
-		dgnc_driver_start = TRUE;
-
-		/* make sure that the globals are init'd before we do anything else */
-		dgnc_init_globals();
+	if (dgnc_driver_start == TRUE)
+		return;
+	dgnc_driver_start = TRUE;
 
-		dgnc_NumBoards = 0;
+	/* make sure that the globals are init'd before we do anything else */
+	dgnc_init_globals();
 
-		APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
+	APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
 
+	/*
+	 * 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.
+	 */
+	if (!dgnc_Major_Control_Registered) {
 		/*
-		 * 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
 		 */
-		if (!dgnc_Major_Control_Registered) {
-			/*
-			 * Register management/dpa devices
-			 */
-			rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
-			if (rc <= 0) {
-				APR(("Can't register dgnc driver device (%d)\n", rc));
-				rc = -ENXIO;
-				return rc;
-			}
-			dgnc_Major = rc;
-
-			dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
-			device_create(dgnc_class, NULL,
-				MKDEV(dgnc_Major, 0),
-				NULL, "dgnc_mgmt");
-			dgnc_Major_Control_Registered = TRUE;
+		rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
+		if (rc <= 0) {
+			APR(("Can't register dgnc driver device (%d)\n", rc));
+			rc = -ENXIO;
+			goto exit;
 		}
+		dgnc_Major = rc;
 
-		/*
-		 * Init any global tty stuff.
-		 */
-		rc = dgnc_tty_preinit();
+		dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
+		device_create(dgnc_class, NULL,
+			MKDEV(dgnc_Major, 0),
+			NULL, "dgnc_mgmt");
+		dgnc_Major_Control_Registered = TRUE;
+	}
 
-		if (rc < 0) {
-			APR(("tty preinit - not enough memory (%d)\n", rc));
-			return rc;
-		}
+	/*
+	 * Init any global tty stuff.
+	 */
+	rc = dgnc_tty_preinit();
 
-		/* Start the poller */
-		DGNC_LOCK(dgnc_poll_lock, flags);
-		init_timer(&dgnc_poll_timer);
-		dgnc_poll_timer.function = dgnc_poll_handler;
-		dgnc_poll_timer.data = 0;
-		dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
-		dgnc_poll_timer.expires = dgnc_poll_time;
-		DGNC_UNLOCK(dgnc_poll_lock, flags);
+	if (rc < 0) {
+		APR(("tty preinit - not enough memory (%d)\n", rc));
+		goto exit;
+	}
 
-		add_timer(&dgnc_poll_timer);
+	/* Start the poller */
+	DGNC_LOCK(dgnc_poll_lock, flags);
+	init_timer(&dgnc_poll_timer);
+	dgnc_poll_timer.function = dgnc_poll_handler;
+	dgnc_poll_timer.data = 0;
+	dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
+	dgnc_poll_timer.expires = dgnc_poll_time;
+	DGNC_UNLOCK(dgnc_poll_lock, flags);
 
-		dgnc_driver_state = DRIVER_READY;
-	}
+	add_timer(&dgnc_poll_timer);
+
+	dgnc_driver_state = DRIVER_READY;
 
+exit:
 	return rc;
 }
 
@@ -814,6 +812,7 @@ static void dgnc_init_globals(void)
 	dgnc_rawreadok		= rawreadok;
 	dgnc_trcbuf_size	= trcbuf_size;
 	dgnc_debug		= debug;
+	dgnc_NumBoards		= 0;
 
 	for (i = 0; i < MAXBOARDS; i++)
 		dgnc_Board[i] = NULL;
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2 6/7] staging: dgnc: Siplify the dgnc_start function
  2014-08-06 13:22               ` [PATCH v2 " Konrad Zapalowicz
@ 2014-08-06 13:31                 ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2014-08-06 13:31 UTC (permalink / raw)
  To: Konrad Zapalowicz; +Cc: lidza.louina, gregkh, driverdev-devel, devel

Sorry, I meant that "return directly" applied for all the new gotos.
Don't do this:

	rc = -ENXIO;
	goto exit;

...
exit:
	return rc;

It just makes the code harder to read.  Do this:

	return -ENXIO;

without all the goto leap hop jumping around.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 6/7 v3] staging: dgnc: Siplify the dgnc_start function
  2014-08-06 12:31             ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Dan Carpenter
  2014-08-06 13:22               ` [PATCH v2 " Konrad Zapalowicz
@ 2014-08-06 13:40               ` Konrad Zapalowicz
  2014-08-06 14:00                 ` [PATCH v3 6/7] " Dan Carpenter
  1 sibling, 1 reply; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-06 13:40 UTC (permalink / raw)
  To: lidza.louina; +Cc: gregkh, driverdev-devel, Konrad Zapalowicz, devel

This commit slightly simplifies the sgnc_start() function by
rearranging it. As a result the indentation level is reduced.
This is not the functional change.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---
 drivers/staging/dgnc/dgnc_driver.c | 91 ++++++++++++++++++--------------------
 1 file changed, 44 insertions(+), 47 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index da7b226..724e4ab 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -278,64 +278,60 @@ static int dgnc_start(void)
 	int rc = 0;
 	unsigned long flags;
 
-	if (dgnc_driver_start == FALSE) {
-
-		dgnc_driver_start = TRUE;
-
-		/* make sure that the globals are init'd before we do anything else */
-		dgnc_init_globals();
+	if (dgnc_driver_start == TRUE)
+		return rc;
+	dgnc_driver_start = TRUE;
 
-		dgnc_NumBoards = 0;
+	/* make sure that the globals are init'd before we do anything else */
+	dgnc_init_globals();
 
-		APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
+	APR(("For the tools package or updated drivers please visit http://www.digi.com\n"));
 
+	/*
+	 * 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.
+	 */
+	if (!dgnc_Major_Control_Registered) {
 		/*
-		 * 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
 		 */
-		if (!dgnc_Major_Control_Registered) {
-			/*
-			 * Register management/dpa devices
-			 */
-			rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
-			if (rc <= 0) {
-				APR(("Can't register dgnc driver device (%d)\n", rc));
-				rc = -ENXIO;
-				return rc;
-			}
-			dgnc_Major = rc;
-
-			dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
-			device_create(dgnc_class, NULL,
-				MKDEV(dgnc_Major, 0),
-				NULL, "dgnc_mgmt");
-			dgnc_Major_Control_Registered = TRUE;
+		rc = register_chrdev(0, "dgnc", &dgnc_BoardFops);
+		if (rc <= 0) {
+			APR(("Can't register dgnc driver device (%d)\n", rc));
+			return -ENXIO;
 		}
+		dgnc_Major = rc;
 
-		/*
-		 * Init any global tty stuff.
-		 */
-		rc = dgnc_tty_preinit();
+		dgnc_class = class_create(THIS_MODULE, "dgnc_mgmt");
+		device_create(dgnc_class, NULL,
+			MKDEV(dgnc_Major, 0),
+			NULL, "dgnc_mgmt");
+		dgnc_Major_Control_Registered = TRUE;
+	}
 
-		if (rc < 0) {
-			APR(("tty preinit - not enough memory (%d)\n", rc));
-			return rc;
-		}
+	/*
+	 * Init any global tty stuff.
+	 */
+	rc = dgnc_tty_preinit();
 
-		/* Start the poller */
-		DGNC_LOCK(dgnc_poll_lock, flags);
-		init_timer(&dgnc_poll_timer);
-		dgnc_poll_timer.function = dgnc_poll_handler;
-		dgnc_poll_timer.data = 0;
-		dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
-		dgnc_poll_timer.expires = dgnc_poll_time;
-		DGNC_UNLOCK(dgnc_poll_lock, flags);
+	if (rc < 0) {
+		APR(("tty preinit - not enough memory (%d)\n", rc));
+		return rc;
+	}
 
-		add_timer(&dgnc_poll_timer);
+	/* Start the poller */
+	DGNC_LOCK(dgnc_poll_lock, flags);
+	init_timer(&dgnc_poll_timer);
+	dgnc_poll_timer.function = dgnc_poll_handler;
+	dgnc_poll_timer.data = 0;
+	dgnc_poll_time = jiffies + dgnc_jiffies_from_ms(dgnc_poll_tick);
+	dgnc_poll_timer.expires = dgnc_poll_time;
+	DGNC_UNLOCK(dgnc_poll_lock, flags);
 
-		dgnc_driver_state = DRIVER_READY;
-	}
+	add_timer(&dgnc_poll_timer);
+
+	dgnc_driver_state = DRIVER_READY;
 
 	return rc;
 }
@@ -814,6 +810,7 @@ static void dgnc_init_globals(void)
 	dgnc_rawreadok		= rawreadok;
 	dgnc_trcbuf_size	= trcbuf_size;
 	dgnc_debug		= debug;
+	dgnc_NumBoards		= 0;
 
 	for (i = 0; i < MAXBOARDS; i++)
 		dgnc_Board[i] = NULL;
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 6/7] staging: dgnc: Siplify the dgnc_start function
  2014-08-06 13:40               ` [PATCH 6/7 v3] " Konrad Zapalowicz
@ 2014-08-06 14:00                 ` Dan Carpenter
  0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2014-08-06 14:00 UTC (permalink / raw)
  To: Konrad Zapalowicz; +Cc: devel, lidza.louina, driverdev-devel, gregkh

On Wed, Aug 06, 2014 at 03:40:11PM +0200, Konrad Zapalowicz wrote:
> This commit slightly simplifies the sgnc_start() function by
> rearranging it. As a result the indentation level is reduced.
> This is not the functional change.
> 
> Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>

Great.  Thanks.

regards,
dan carpenter

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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/7] staging: dgnc: Fix externs should be avoided in the .c files
  2014-08-06 12:21 [PATCH 0/7] staging: dgnc: cleanup of the dgnc_driver.c Konrad Zapalowicz
  2014-08-06 12:21 ` [PATCH 1/7] staging: dgnc: Fix externs should be avoided in the .c files Konrad Zapalowicz
@ 2014-08-12  6:08 ` Konrad Zapalowicz
  1 sibling, 0 replies; 14+ messages in thread
From: Konrad Zapalowicz @ 2014-08-12  6:08 UTC (permalink / raw)
  To: lidza.louina; +Cc: markh, gregkh, driverdev-devel, devel, Konrad Zapalowicz

This commit fixes the following checkpatch warnings:

WARNING: externs should be avoided in .c files
    #80: FILE: drivers/staging/dgnc/dgnc_driver.c:80:
        +int            dgnc_init_module(void);
    #81: FILE: drivers/staging/dgnc/dgnc_driver.c:81:
        +void           dgnc_cleanup_module(void);

This was caused by putting the declarations for module init and module
exit fucntions on the top of the file. The fix removes these
declarations plus it also corrects the type of the init/exit functions.

Due to the dependency between init and exit functions the
dgnc_cleanup_module had to be put first.

Signed-off-by: Konrad Zapalowicz <bergo.torino@gmail.com>
---

 v2:
   - remove the __exit annotation for the cleanup function as it caused
     the test-bot unhappy.

 drivers/staging/dgnc/dgnc_driver.c | 84 ++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 45 deletions(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 764613b..2c2abf8 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -76,12 +76,6 @@ static void		dgnc_remove_one(struct pci_dev *dev);
 static int		dgnc_probe1(struct pci_dev *pdev, int card_type);
 static void		dgnc_do_remap(struct dgnc_board *brd);
 
-/* Driver load/unload functions */
-int		dgnc_init_module(void);
-void		dgnc_cleanup_module(void);
-
-module_init(dgnc_init_module);
-module_exit(dgnc_cleanup_module);
 
 
 /*
@@ -199,13 +193,49 @@ char *dgnc_driver_state_text[] = {
  *
  ************************************************************************/
 
+/*
+ * dgnc_cleanup_module()
+ *
+ * Module unload.  This is where it all ends.
+ */
+static void dgnc_cleanup_module(void)
+{
+	int i;
+	ulong lock_flags;
+
+	DGNC_LOCK(dgnc_poll_lock, lock_flags);
+	dgnc_poll_stop = 1;
+	DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
+
+	/* Turn off poller right away. */
+	del_timer_sync(&dgnc_poll_timer);
+
+	dgnc_remove_driver_sysfiles(&dgnc_driver);
+
+	if (dgnc_Major_Control_Registered) {
+		device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
+		class_destroy(dgnc_class);
+		unregister_chrdev(dgnc_Major, "dgnc");
+	}
+
+	for (i = 0; i < dgnc_NumBoards; ++i) {
+		dgnc_remove_ports_sysfiles(dgnc_Board[i]);
+		dgnc_tty_uninit(dgnc_Board[i]);
+		dgnc_cleanup_board(dgnc_Board[i]);
+	}
+
+	dgnc_tty_post_uninit();
+
+	if (dgnc_NumBoards)
+		pci_unregister_driver(&dgnc_driver);
+}
 
 /*
  * init_module()
  *
  * Module load.  This is where it all starts.
  */
-int dgnc_init_module(void)
+static int __init dgnc_init_module(void)
 {
 	int rc = 0;
 
@@ -243,6 +273,8 @@ int dgnc_init_module(void)
 	return rc;
 }
 
+module_init(dgnc_init_module);
+module_exit(dgnc_cleanup_module);
 
 /*
  * Start of driver.
@@ -355,44 +387,6 @@ static void dgnc_remove_one(struct pci_dev *dev)
 }
 
 /*
- * dgnc_cleanup_module()
- *
- * Module unload.  This is where it all ends.
- */
-void dgnc_cleanup_module(void)
-{
-	int i;
-	ulong lock_flags;
-
-	DGNC_LOCK(dgnc_poll_lock, lock_flags);
-	dgnc_poll_stop = 1;
-	DGNC_UNLOCK(dgnc_poll_lock, lock_flags);
-
-	/* Turn off poller right away. */
-	del_timer_sync(&dgnc_poll_timer);
-
-	dgnc_remove_driver_sysfiles(&dgnc_driver);
-
-	if (dgnc_Major_Control_Registered) {
-		device_destroy(dgnc_class, MKDEV(dgnc_Major, 0));
-		class_destroy(dgnc_class);
-		unregister_chrdev(dgnc_Major, "dgnc");
-	}
-
-	for (i = 0; i < dgnc_NumBoards; ++i) {
-		dgnc_remove_ports_sysfiles(dgnc_Board[i]);
-		dgnc_tty_uninit(dgnc_Board[i]);
-		dgnc_cleanup_board(dgnc_Board[i]);
-	}
-
-	dgnc_tty_post_uninit();
-
-	if (dgnc_NumBoards)
-		pci_unregister_driver(&dgnc_driver);
-}
-
-
-/*
  * dgnc_cleanup_board()
  *
  * Free all the memory associated with a board
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-08-12  6:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06 12:21 [PATCH 0/7] staging: dgnc: cleanup of the dgnc_driver.c Konrad Zapalowicz
2014-08-06 12:21 ` [PATCH 1/7] staging: dgnc: Fix externs should be avoided in the .c files Konrad Zapalowicz
2014-08-06 12:21   ` [PATCH 2/7] staging: dgnc: Fix no spaces before tabs checkpath warning Konrad Zapalowicz
2014-08-06 12:21     ` [PATCH 3/7] staging: dgnc: Fix frame size is larger than 1024B Konrad Zapalowicz
2014-08-06 12:21       ` [PATCH 4/7] staging: dgnc: Remove unnecessary functions from dgnc_driver.c Konrad Zapalowicz
2014-08-06 12:21         ` [PATCH 5/7] staging: dgnc: Move utility functions out of dgnc_driver.c Konrad Zapalowicz
2014-08-06 12:21           ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Konrad Zapalowicz
2014-08-06 12:21             ` [PATCH 7/7] staging: dgnc: Update the TODO file Konrad Zapalowicz
2014-08-06 12:31             ` [PATCH 6/7] staging: dgnc: Siplify the dgnc_start function Dan Carpenter
2014-08-06 13:22               ` [PATCH v2 " Konrad Zapalowicz
2014-08-06 13:31                 ` Dan Carpenter
2014-08-06 13:40               ` [PATCH 6/7 v3] " Konrad Zapalowicz
2014-08-06 14:00                 ` [PATCH v3 6/7] " Dan Carpenter
2014-08-12  6:08 ` [PATCH v2 1/7] staging: dgnc: Fix externs should be avoided in the .c files Konrad Zapalowicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.