Skip to contentSkip to conversation

mei: cleanup some checkpatch issues

PATCH In review Tomas Winkler 2 participants 9 messages Mar 16, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover mei: cleanup some checkpatch issues

Tomas Winkler (5):
mei: fix Unnecessary space after function pointer name
mei: use cl_dbg where appropriate
mei: client.h fix checkpetch errors
mei: amthif: fix checkpatch error
mei: don't use deprecated DEFINE_PCI_DEVICE_TABLE macro

 drivers/misc/mei/amthif.c  |  3 +--
 drivers/misc/mei/client.h  |  8 ++++----
 drivers/misc/mei/hbm.c     |  3 +--
 drivers/misc/mei/main.c    | 10 ++--------
 drivers/misc/mei/mei_dev.h | 24 ++++++++++++------------
 drivers/misc/mei/pci-me.c  |  2 +-
 drivers/misc/mei/pci-txe.c |  2 +-
 7 files changed, 22 insertions(+), 30 deletions(-)
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 1/5 mei: fix Unnecessary space after function pointer name

Fix checkpatch warining:
Unnecessary space after function pointer name

---
 drivers/misc/mei/mei_dev.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/misc/mei/mei_dev.h +12 -12
index 2ef5593..94a5167 100644
@@ -237,20 +237,20 @@ struct mei_cl {
  */
 struct mei_hw_ops {
 
-	bool (*host_is_ready) (struct mei_device *dev);
+	bool (*host_is_ready)(struct mei_device *dev);
 
-	bool (*hw_is_ready) (struct mei_device *dev);
-	int (*hw_reset) (struct mei_device *dev, bool enable);
-	int  (*hw_start) (struct mei_device *dev);
-	void (*hw_config) (struct mei_device *dev);
+	bool (*hw_is_ready)(struct mei_device *dev);
+	int (*hw_reset)(struct mei_device *dev, bool enable);
+	int (*hw_start)(struct mei_device *dev);
+	void (*hw_config)(struct mei_device *dev);
 
-	void (*intr_clear) (struct mei_device *dev);
-	void (*intr_enable) (struct mei_device *dev);
-	void (*intr_disable) (struct mei_device *dev);
+	void (*intr_clear)(struct mei_device *dev);
+	void (*intr_enable)(struct mei_device *dev);
+	void (*intr_disable)(struct mei_device *dev);
 
-	int (*hbuf_free_slots) (struct mei_device *dev);
-	bool (*hbuf_is_ready) (struct mei_device *dev);
-	size_t (*hbuf_max_len) (const struct mei_device *dev);
+	int (*hbuf_free_slots)(struct mei_device *dev);
+	bool (*hbuf_is_ready)(struct mei_device *dev);
+	size_t (*hbuf_max_len)(const struct mei_device *dev);
 
 	int (*write)(struct mei_device *dev,
 		     struct mei_msg_hdr *hdr,
@@ -259,7 +259,7 @@ struct mei_hw_ops {
 	int (*rdbuf_full_slots)(struct mei_device *dev);
 
 	u32 (*read_hdr)(const struct mei_device *dev);
-	int (*read) (struct mei_device *dev,
+	int (*read)(struct mei_device *dev,
 		     unsigned char *buf, unsigned long len);
 };
 
Signature · 1 line
1.8.5.3
#2 lore raw

PATCH 2/5 mei: use cl_dbg where appropriate

In reply to Tomas Winkler

use cl_dbg for debug log messages in cl context

this also removes checkpatch warning:
quoted string split across lines

---
 drivers/misc/mei/hbm.c  |  3 +--
 drivers/misc/mei/main.c | 10 ++--------
 2 files changed, 3 insertions(+), 10 deletions(-)
drivers/misc/mei/hbm.c +1 -2
index 5fa5ff9..4960288 100644
@@ -329,8 +329,7 @@ int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
 	mei_hbm_hdr(mei_hdr, len);
 	mei_hbm_cl_hdr(cl, MEI_FLOW_CONTROL_CMD, dev->wr_msg.data, len);
 
-	dev_dbg(&dev->pdev->dev, "sending flow control host client = %d, ME client = %d\n",
-		cl->host_client_id, cl->me_client_id);
+	cl_dbg(dev, cl, "sending flow control\n");
 
 	return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
 }
drivers/misc/mei/main.c +2 -8
index bc1c39e..b35594d 100644
@@ -125,17 +125,11 @@ static int mei_release(struct inode *inode, struct file *file)
 	}
 	if (cl->state == MEI_FILE_CONNECTED) {
 		cl->state = MEI_FILE_DISCONNECTING;
-		dev_dbg(&dev->pdev->dev,
-			"disconnecting client host client = %d, "
-		    "ME client = %d\n",
-		    cl->host_client_id,
-		    cl->me_client_id);
+		cl_dbg(dev, cl, "disconnecting\n");
 		rets = mei_cl_disconnect(cl);
 	}
 	mei_cl_flush_queues(cl);
-	dev_dbg(&dev->pdev->dev, "remove client host client = %d, ME client = %d\n",
-	    cl->host_client_id,
-	    cl->me_client_id);
+	cl_dbg(dev, cl, "removing\n");
 
 	mei_cl_unlink(cl);
 
Signature · 1 line
1.8.5.3
#3 lore raw

Re: [char-misc-next 2/5] mei: use cl_dbg where appropriate

Quoted 1 line · Tomas Winkler

use cl_dbg for debug log messages in cl context

I think all the uses of cl_dbg and cl_err are odd.

from: client.h

#define cl_dbg(dev, cl, format, arg...) \
	dev_dbg(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
#define cl_err(dev, cl, format, arg...) \
	dev_err(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)

dev is always passed separately from cl but
dev is set like:

	struct mei_device *dev;
[]
	dev = cl->dev;

So I think these should be converted to:

#define cl_dbg(cl, format, ...) \
	dev_dbg(&(cl)->dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##__VA_ARGS__)

and the uses from (as an example):

client.c:942: cl_dbg(dev, cl, "Waking up reading client!\n");

to

client.c:942: cl_dbg(cl, "Waking up reading client!\n");

This can also remove some used once declarations of dev

#4 lore raw

RE: [char-misc-next 2/5] mei: use cl_dbg where appropriate

Quoted 30 lines · Tomas Winkler
Quoted 1 line

use cl_dbg for debug log messages in cl context

I think all the uses of cl_dbg and cl_err are odd.

from: client.h

#define cl_dbg(dev, cl, format, arg...) \
	dev_dbg(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl),

##arg)

#define cl_err(dev, cl, format, arg...) \
	dev_err(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)

dev is always passed separately from cl but
dev is set like:

	struct mei_device *dev;
[]
	dev = cl->dev;

So I think these should be converted to:

#define cl_dbg(cl, format, ...) \
	dev_dbg(&(cl)->dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl),

##__VA_ARGS__)

and the uses from (as an example):

Quoted 7 lines

client.c:942: cl_dbg(dev, cl, "Waking up reading client!\n");

to

client.c:942: cl_dbg(cl, "Waking up reading client!\n");

This can also remove some used once declarations of dev

Yes, I'm aware of this, at the time I've preferred consistently passing dev as a first argument. It can be changed I just personally don't feel some big gain.

Tomas

#5 lore raw

Re: [char-misc-next 2/5] mei: use cl_dbg where appropriate

Quoted 3 lines · Tomas
Quoted 3 lines
#define cl_dbg(dev, cl, format, arg...) \
	dev_dbg(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl),

##arg)

[]

Quoted 3 lines
Quoted 3 lines
#define cl_dbg(cl, format, ...) \
	dev_dbg(&(cl)->dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl),

##__VA_ARGS__)

[]

Quoted 2 lines

Yes, I'm aware of this, at the time I've preferred consistently passing dev as a first argument. It can be changed I just personally don't feel some big gain.

I do wonder about the mixture of dev_dbg and cl_dbg. Was there any rationale about this mixture?

Here's a potential cleanup

From: Joe Perches <[email protected]>
Date: Sun, 16 Mar 2014 15:55:06 -0700
Subject: [PATCH] mei: Remove unnecessary dev arg from cl_<level> logging

dev is a member of cl so use that instead.

Add missing newlines.
Neaten logging messages and alignment.
Remove now unnecessary declaration too.

---
 drivers/misc/mei/amthif.c    |  2 +-
 drivers/misc/mei/client.c    | 53 +++++++++++++++++++-------------------------
 drivers/misc/mei/client.h    | 16 ++++++++-----
 drivers/misc/mei/hbm.c       |  4 ++--
 drivers/misc/mei/interrupt.c | 20 ++++++++---------
 drivers/misc/mei/main.c      |  4 ++--
 drivers/misc/mei/pci-me.c    |  2 +-
 7 files changed, 50 insertions(+), 51 deletions(-)
drivers/misc/mei/amthif.c +1 -1
index f05d54d..7bb66c7 100644
@@ -458,7 +458,7 @@ int mei_amthif_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
 		return rets;
 
 	if (rets == 0) {
-		cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
+		cl_dbg(cl, "No flow control credentials: not sending\n");
 		return 0;
 	}
 
drivers/misc/mei/client.c +23 -30

170 lines not on this page · raw message

drivers/misc/mei/client.h +11 -5
index 257aa5f..ddc9979 100644
@@ -118,10 +118,16 @@ void mei_cl_all_write_clear(struct mei_device *dev);
 #define MEI_CL_FMT "cl:host=%02d me=%02d "
 #define MEI_CL_PRM(cl) (cl)->host_client_id, (cl)->me_client_id
 
-#define cl_dbg(dev, cl, format, arg...) \
-	dev_dbg(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
-
-#define cl_err(dev, cl, format, arg...) \
-	dev_err(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
+#define cl_dbg(cl, fmt, ...)						\
+	dev_dbg(&(cl)->dev->pdev->dev,					\
+		"cl:host=%02d me=%02d " fmt,				\
+		(cl)->host_client_id, (cl)->me_client_id,		\
+		##__VA_ARGS__)
+
+#define cl_err(cl, fmt, ...)						\
+	dev_err(&(cl)->dev->pdev->dev,					\
+		"cl:host=%02d me=%02d " fmt,				\
+		(cl)->host_client_id, (cl)->me_client_id,		\
+		##__VA_ARGS__)
 
 #endif /* _MEI_CLIENT_H_ */
drivers/misc/mei/hbm.c +2 -2
index dd7a788..a063bb4 100644
@@ -330,7 +330,7 @@ int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
 	mei_hbm_hdr(mei_hdr, len);
 	mei_hbm_cl_hdr(cl, MEI_FLOW_CONTROL_CMD, dev->wr_msg.data, len);
 
-	cl_dbg(dev, cl, "sending flow control\n");
+	cl_dbg(cl, "sending flow control\n");
 
 	return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
 }
@@ -570,7 +570,7 @@ static int mei_hbm_fw_disconnect_req(struct mei_device *dev,
 			if (!cb)
 				return -ENOMEM;
 			cb->fop_type = MEI_FOP_DISCONNECT_RSP;
-			cl_dbg(dev, cl, "add disconnect response as first\n");
+			cl_dbg(cl, "add disconnect response as first\n");
 			list_add(&cb->list, &dev->ctrl_wr_list.list);
 
 			break;
drivers/misc/mei/interrupt.c +10 -10
index 2fbf0c0..351e568 100644
@@ -113,21 +113,21 @@ static int mei_cl_irq_read_msg(struct mei_device *dev,
 
 		if (cb->response_buffer.size == 0 ||
 		    cb->response_buffer.data == NULL) {
-			cl_err(dev, cl, "response buffer is not allocated.\n");
+			cl_err(cl, "response buffer is not allocated\n");
 			list_del(&cb->list);
 			return -ENOMEM;
 		}
 
 		if (cb->response_buffer.size < mei_hdr->length + cb->buf_idx) {
-			cl_dbg(dev, cl, "message overflow. size %d len %d idx %ld\n",
-				cb->response_buffer.size,
-				mei_hdr->length, cb->buf_idx);
+			cl_dbg(cl, "message overflow. size %d len %d idx %ld\n",
+			       cb->response_buffer.size,
+			       mei_hdr->length, cb->buf_idx);
 			buffer = krealloc(cb->response_buffer.data,
 					  mei_hdr->length + cb->buf_idx,
 					  GFP_KERNEL);
 
 			if (!buffer) {
-				cl_err(dev, cl, "allocation failed.\n");
+				cl_err(cl, "allocation failed\n");
 				list_del(&cb->list);
 				return -ENOMEM;
 			}
@@ -143,8 +143,8 @@ static int mei_cl_irq_read_msg(struct mei_device *dev,
 		if (mei_hdr->msg_complete) {
 			cl->status = 0;
 			list_del(&cb->list);
-			cl_dbg(dev, cl, "completed read length = %lu\n",
-				cb->buf_idx);
+			cl_dbg(cl, "completed read length = %lu\n",
+			       cb->buf_idx);
 			list_add_tail(&cb->list, &complete_list->list);
 		}
 		break;
@@ -369,7 +369,7 @@ int mei_irq_read_handler(struct mei_device *dev,
 	/* find recipient cl */
 	list_for_each_entry(cl, &dev->file_list, link) {
 		if (mei_cl_hbm_equal(cl, mei_hdr)) {
-			cl_dbg(dev, cl, "got a message\n");
+			cl_dbg(cl, "got a message\n");
 			break;
 		}
 	}
@@ -459,12 +459,12 @@ int mei_irq_write_handler(struct mei_device *dev, struct mei_cl_cb *cmpl_list)
 		if (MEI_WRITING == cl->writing_state &&
 		    cb->fop_type == MEI_FOP_WRITE &&
 		    cl != &dev->iamthif_cl) {
-			cl_dbg(dev, cl, "MEI WRITE COMPLETE\n");
+			cl_dbg(cl, "MEI WRITE COMPLETE\n");
 			cl->writing_state = MEI_WRITE_COMPLETE;
 			list_add_tail(&cb->list, &cmpl_list->list);
 		}
 		if (cl == &dev->iamthif_cl) {
-			cl_dbg(dev, cl, "check iamthif flow control.\n");
+			cl_dbg(cl, "check iamthif flow control\n");
 			if (dev->iamthif_flow_control_pending) {
 				ret = mei_amthif_irq_read(dev, &slots);
 				if (ret)
drivers/misc/mei/main.c +2 -2
index 51c737f5..15c1ac2 100644
@@ -129,11 +129,11 @@ static int mei_release(struct inode *inode, struct file *file)
 	}
 	if (cl->state == MEI_FILE_CONNECTED) {
 		cl->state = MEI_FILE_DISCONNECTING;
-		cl_dbg(dev, cl, "disconnecting\n");
+		cl_dbg(cl, "disconnecting\n");
 		rets = mei_cl_disconnect(cl);
 	}
 	mei_cl_flush_queues(cl);
-	cl_dbg(dev, cl, "removing\n");
+	cl_dbg(cl, "removing\n");
 
 	mei_cl_unlink(cl);
 
drivers/misc/mei/pci-me.c +1 -1
index 50d9cb5..bd7bf00 100644
@@ -43,7 +43,7 @@
 #include "client.h"
 
 /* mei_pci_tbl - PCI Device ID Table */
-static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
+static const struct pci_device_id mei_me_pci_tbl[] = {
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)},
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)},
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)},
Signature · 1 line
1.8.1.2.459.gbcd45b4.dirty
#6 lore raw

PATCH 3/5 mei: client.h fix checkpetch errors

In reply to Tomas Winkler

Fix checkpatch error
return is not a function, parentheses are not required

---
 drivers/misc/mei/client.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/misc/mei/client.h +4 -4
index 8139393..96d5de0 100644
@@ -68,15 +68,15 @@ int mei_cl_flow_ctrl_reduce(struct mei_cl *cl);
  */
 static inline bool mei_cl_is_connected(struct mei_cl *cl)
 {
-	return (cl->dev &&
+	return  cl->dev &&
 		cl->dev->dev_state == MEI_DEV_ENABLED &&
-		cl->state == MEI_FILE_CONNECTED);
+		cl->state == MEI_FILE_CONNECTED;
 }
 static inline bool mei_cl_is_transitioning(struct mei_cl *cl)
 {
-	return (MEI_FILE_INITIALIZING == cl->state ||
+	return  MEI_FILE_INITIALIZING == cl->state ||
 		MEI_FILE_DISCONNECTED == cl->state ||
-		MEI_FILE_DISCONNECTING == cl->state);
+		MEI_FILE_DISCONNECTING == cl->state;
 }
 
 bool mei_cl_is_other_connecting(struct mei_cl *cl);
Signature · 1 line
1.8.5.3
#7 lore raw

PATCH 4/5 mei: amthif: fix checkpatch error

In reply to Tomas Winkler

ERROR: else should follow close brace '}'
+ }
+ else {

---
 drivers/misc/mei/amthif.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/mei/amthif.c +1 -2
index 2052609..b8deb34 100644
@@ -247,8 +247,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
 	if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
 		dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
 		rets = -EFAULT;
-	}
-	else {
+	} else {
 		rets = length;
 		if ((*offset + length) < cb->buf_idx) {
 			*offset += length;
Signature · 1 line
1.8.5.3
#8 lore raw

PATCH 5/5 mei: don't use deprecated DEFINE_PCI_DEVICE_TABLE macro

In reply to Tomas Winkler

Using struct pci_device_id is preferred over
deprecated DEFINE_PCI_DEVICE_TABLE macro

---
 drivers/misc/mei/pci-me.c  | 2 +-
 drivers/misc/mei/pci-txe.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/misc/mei/pci-me.c +1 -1
index 135ea06..1c8fd3a 100644
@@ -41,7 +41,7 @@
 #include "hw-me.h"
 
 /* mei_pci_tbl - PCI Device ID Table */
-static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
+static const struct pci_device_id mei_me_pci_tbl[] = {
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82946GZ)},
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82G35)},
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_82Q965)},
drivers/misc/mei/pci-txe.c +1 -1
index a5bf39a..ad3adb0 100644
@@ -34,7 +34,7 @@
 #include "mei_dev.h"
 #include "hw-txe.h"
 
-static DEFINE_PCI_DEVICE_TABLE(mei_txe_pci_tbl) = {
+static const struct pci_device_id mei_txe_pci_tbl[] = {
 	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x0F18)}, /* Baytrail */
 	{0, }
 };
Signature · 1 line
1.8.5.3