Skip to contentSkip to conversation

Staging: dgnc: dgnc_driver: fixed coding style of dgnc_pci_tbl

PATCH New Son P. Nguyen 2 participants 5 messages Apr 20, 2014 – Apr 22, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Staging: dgnc: dgnc_driver: fixed coding style of dgnc_pci_tbl

From: "Son P. Nguyen" <[email protected]>

Fixed coding style of dgnc_pci_tbl definition (longer than 80 chars)

---
 drivers/staging/dgnc/dgnc_driver.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)
drivers/staging/dgnc/dgnc_driver.c +19 -17
index b1a39b2..e91d3a7 100644
@@ -124,25 +124,27 @@ 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;
 
+#define DIGIVID_PCI_DEVICE_ID(subdevice, driver_data) \
+	{ DIGI_VID, PCI_DEVICE_##subdevice, PCI_ANY_ID, 0, 0, driver_data }
 
 static struct pci_device_id dgnc_pci_tbl[] = {
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	0 },
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	1 },
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	2 },
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_8_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	3 },
-	{	DIGI_VID, PCI_DEVICE_NEO_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,		4 },
-	{	DIGI_VID, PCI_DEVICE_NEO_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,		5 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2DB9_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	6 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2DB9PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	7 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	8 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2RJ45PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	9 },
-	{	DIGI_VID, PCI_DEVICE_NEO_1_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	10 },
-	{	DIGI_VID, PCI_DEVICE_NEO_1_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	11 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	12 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	 13 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	14 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	15 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	16 },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_4_DID,		0 },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_4_422_DID,	1 },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_8_DID,		2 },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_8_422_DID,	3 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_4_DID,		4 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_8_DID,		5 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2DB9_DID,		6 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2DB9PRI_DID,	7 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2RJ45_DID,		8 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2RJ45PRI_DID,	9 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_1_422_DID,		10 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_1_422_485_DID,	11 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2_422_485_DID,	12 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_8_DID,	13 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_4_DID,	14 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_4RJ45_DID,	15 },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_8RJ45_DID,	16 },
 	{0,}						/* 0 terminated list. */
 };
 MODULE_DEVICE_TABLE(pci, dgnc_pci_tbl);
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 Staging: dgnc: dgnc_driver: fixed coding style braces

From: "Son P. Nguyen" <[email protected]>

Fixed incorrect braces (coding style)

PS: This is for task 10 of eudyptula-challenge.

---
 drivers/staging/dgnc/dgnc_driver.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/staging/dgnc/dgnc_driver.c +6 -11
index e91d3a7..c8b02f5 100644
@@ -88,8 +88,7 @@ module_exit(dgnc_cleanup_module);
 /*
  * File operations permitted on Control/Management major.
  */
-static const struct file_operations dgnc_BoardFops =
-{
+static const struct file_operations dgnc_BoardFops = {
 	.owner		=	THIS_MODULE,
 	.unlocked_ioctl =  	dgnc_mgmt_ioctl,
 	.open		=	dgnc_mgmt_open,
@@ -155,8 +154,7 @@ struct board_id {
 	unsigned int is_pci_express;
 };
 
-static struct board_id dgnc_Ids[] =
-{
+static struct board_id dgnc_Ids[] = {
 	{	PCI_DEVICE_CLASSIC_4_PCI_NAME,		4,	0	},
 	{	PCI_DEVICE_CLASSIC_4_422_PCI_NAME,	4,	0	},
 	{	PCI_DEVICE_CLASSIC_8_PCI_NAME,		8,	0	},
@@ -221,9 +219,8 @@ int dgnc_init_module(void)
 	 */
 	rc = dgnc_start();
 
-	if (rc < 0) {
+	if (rc < 0)
 		return rc;
-	}
 
 	/*
 	 * Find and configure all the cards
@@ -241,8 +238,7 @@ int dgnc_init_module(void)
 			pr_warn("WARNING: dgnc driver load failed.  No Digi Neo or Classic boards found.\n");
 
 		dgnc_cleanup_module();
-	}
-	else {
+	} else {
 		dgnc_create_driver_sysfiles(&dgnc_driver);
 	}
 
@@ -521,9 +517,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
 	brd->state		= BOARD_FOUND;
 
-	for (i = 0; i < MAXPORTS; i++) {
-		brd->channels[i] = NULL;
-	}
+	for (i = 0; i < MAXPORTS; i++)
+		brd->channels[i] = NULL;	
 
 	/* store which card & revision we have */
 	pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
Signature · 1 line
1.8.1.2
#2 lore raw

PATCH v2 1/2 Staging: dgnc: dgnc_driver: fixed dgnc_pci_tbl definition

From: "Son P. Nguyen" <[email protected]>

Fixed dgnc_pci_tbl definition for correct coding style

PS: This is for task 10 of eudyptula-challenge.

---
 drivers/staging/dgnc/dgnc_driver.c | 39 +++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)
drivers/staging/dgnc/dgnc_driver.c +22 -17
index b1a39b2..6af1ab3 100644
@@ -125,26 +125,31 @@ static uint		dgnc_poll_stop;				/* Used to tell poller to stop */
 static struct timer_list dgnc_poll_timer;
 
 
+
+#define DIGIVID_PCI_DEVICE_ID(subdevice, driver_data) \
+	{ DIGI_VID, PCI_DEVICE_##subdevice, PCI_ANY_ID, 0, 0, driver_data }
+
 static struct pci_device_id dgnc_pci_tbl[] = {
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	0 },
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_4_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	1 },
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	2 },
-	{	DIGI_VID, PCI_DEVICE_CLASSIC_8_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	3 },
-	{	DIGI_VID, PCI_DEVICE_NEO_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,		4 },
-	{	DIGI_VID, PCI_DEVICE_NEO_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,		5 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2DB9_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	6 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2DB9PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	7 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	8 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2RJ45PRI_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	9 },
-	{	DIGI_VID, PCI_DEVICE_NEO_1_422_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	10 },
-	{	DIGI_VID, PCI_DEVICE_NEO_1_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	11 },
-	{	DIGI_VID, PCI_DEVICE_NEO_2_422_485_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	12 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	 13 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	14 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_4RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	15 },
-	{	DIGI_VID, PCI_DEVICE_NEO_EXPRESS_8RJ45_DID, PCI_ANY_ID, PCI_ANY_ID, 0, 0,	16 },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_4_DID,		0) },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_4_422_DID,	1) },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_8_DID,		2) },
+	{ DIGIVID_PCI_DEVICE_ID(CLASSIC_8_422_DID,	3) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_4_DID,		4) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_8_DID,		5) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2DB9_DID,		6) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2DB9PRI_DID,	7) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2RJ45_DID,		8) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2RJ45PRI_DID,	9) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_1_422_DID,		10) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_1_422_485_DID,	11) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_2_422_485_DID,	12) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_8_DID,	13) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_4_DID,	14) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_4RJ45_DID,	15) },
+	{ DIGIVID_PCI_DEVICE_ID(NEO_EXPRESS_8RJ45_DID,	16) },
 	{0,}						/* 0 terminated list. */
 };
+
 MODULE_DEVICE_TABLE(pci, dgnc_pci_tbl);
 
 struct board_id {
Signature · 1 line
1.8.1.2
#3 lore raw

PATCH v2 2/2 Staging: dgnc: dgnc_driver: fixed incorrect braces

From: "Son P. Nguyen" <[email protected]>

Fixed incorrect braces (coding style)

---
 drivers/staging/dgnc/dgnc_driver.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/staging/dgnc/dgnc_driver.c +7 -14
index 6af1ab3..de76eb5 100644
@@ -158,8 +158,7 @@ struct board_id {
 	unsigned int is_pci_express;
 };
 
-static struct board_id dgnc_Ids[] =
-{
+static struct board_id dgnc_Ids[] = {
 	{	PCI_DEVICE_CLASSIC_4_PCI_NAME,		4,	0	},
 	{	PCI_DEVICE_CLASSIC_4_422_PCI_NAME,	4,	0	},
 	{	PCI_DEVICE_CLASSIC_8_PCI_NAME,		8,	0	},
@@ -224,9 +223,8 @@ int dgnc_init_module(void)
 	 */
 	rc = dgnc_start();
 
-	if (rc < 0) {
+	if (rc < 0)
 		return rc;
-	}
 
 	/*
 	 * Find and configure all the cards
@@ -244,8 +242,7 @@ int dgnc_init_module(void)
 			pr_warn("WARNING: dgnc driver load failed.  No Digi Neo or Classic boards found.\n");
 
 		dgnc_cleanup_module();
-	}
-	else {
+	} else {
 		dgnc_create_driver_sysfiles(&dgnc_driver);
 	}
 
@@ -524,9 +521,8 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
 
 	brd->state		= BOARD_FOUND;
 
-	for (i = 0; i < MAXPORTS; i++) {
+	for (i = 0; i < MAXPORTS; i++)
 		brd->channels[i] = NULL;
-	}
 
 	/* store which card & revision we have */
 	pci_read_config_word(pdev, PCI_SUBSYSTEM_VENDOR_ID, &brd->subvendor);
@@ -804,9 +800,8 @@ static void dgnc_poll_handler(ulong dummy)
 	 * driver tells us its up and running, and has
 	 * everything it needs.
 	 */
-	if (dgnc_driver_state != DRIVER_READY) {
+	if (dgnc_driver_state != DRIVER_READY)
 		goto schedule_poller;
-	}
 
 	/* Go thru each board, kicking off a tasklet for each if needed */
 	for (i = 0; i < dgnc_NumBoards; i++) {
@@ -836,9 +831,8 @@ schedule_poller:
 
 	new_time = dgnc_poll_time - jiffies;
 
-	if ((ulong) new_time >= 2 * dgnc_poll_tick) {
+	if ((ulong) new_time >= 2 * dgnc_poll_tick)
 		dgnc_poll_time = jiffies +  dgnc_jiffies_from_ms(dgnc_poll_tick);
-	}
 
 	init_timer(&dgnc_poll_timer);
 	dgnc_poll_timer.function = dgnc_poll_handler;
@@ -865,9 +859,8 @@ static void dgnc_init_globals(void)
 	dgnc_trcbuf_size	= trcbuf_size;
 	dgnc_debug		= debug;
 
-	for (i = 0; i < MAXBOARDS; i++) {
+	for (i = 0; i < MAXBOARDS; i++)
 		dgnc_Board[i] = NULL;
-	}
 
 	init_timer(&dgnc_poll_timer);
 }
Signature · 1 line
1.8.1.2
#4 lore raw

Re: [PATCH v2 1/2] Staging: dgnc: dgnc_driver: fixed dgnc_pci_tbl definition

In reply to Son P. Nguyen

I like the idea of this patch but the v2 version still doesn't compile. I don't understand how you can write such a nice patch and not even test that it compiles. Twice. That's not ok.

Quoted 1 line · Son P. Nguyen

From: "Son P. Nguyen" <[email protected]>

Don't include this when you are sending your own patch.

Quoted 2 lines

Fixed dgnc_pci_tbl definition for correct coding style

This description is not enough.

Quoted 2 lines

PS: This is for task 10 of eudyptula-challenge.

Don't include this line.

regards,
dan carpenter