Skip to contentSkip to conversation

staging: most: hdm-usb: convert pr_warn() to dev_warn()

PATCH Superseded Eva Rachel Retuya 2 participants 4 messages Sep 19, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: most: hdm-usb: convert pr_warn() to dev_warn()

Replace pr_warn() call with its respective dev_warn() counterpart. Semantic patch used to detect and apply the transformation:

@a@
identifier f, dev;
expression fmt, E;
@@

f(...) {
	...
	struct device *dev = E;
	<+... when != dev == NULL
- pr_warn(
+ dev_warn(dev,
		fmt, ...);
	...+>
}
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/hdm-usb/hdm_usb.c +2 -2
index 5b27e96..6fc20b1 100644
@@ -1315,8 +1315,8 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
 				  ep_desc->bEndpointAddress * 16,
 				  1);
 		if (err < 0)
-			pr_warn("DCI Sync for EP %02x failed",
-				ep_desc->bEndpointAddress);
+			dev_warn(dev, "DCI Sync for EP %02x failed",
+				 ep_desc->bEndpointAddress);
 	}
 	dev_notice(dev, "claimed gadget: Vendor=%4.4x ProdID=%4.4x Bus=%02x Device=%02x\n",
 		   le16_to_cpu(usb_dev->descriptor.idVendor),
Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines

@a@
identifier f, dev;
expression fmt, E;
@@

Quoted 9 lines
f(...) {
	...
	struct device *dev = E;
	<+... when != dev == NULL
- pr_warn(
+ dev_warn(dev,
		fmt, ...);
	...+>
}

This is a good idea, but it is unnecessarily inefficient in the details. You don't use the function name f, so there is no need to match the entire function. Matching the entire function causes Coccinelle to go through all of its possible control-flow paths (loops, conditional branches, etc.), which can be expensive. You can instead just start at struct device *dev = E;. Also, you don't do anything with fmt, so you can drop that, and just put ... for the remaining arguments.

julia

#2 lore raw
Quoted 23 lines · Julia Lawall
Quoted 5 lines

@a@
identifier f, dev;
expression fmt, E;
@@

Quoted 9 lines
f(...) {
	...
	struct device *dev = E;
	<+... when != dev == NULL
- pr_warn(
+ dev_warn(dev,
		fmt, ...);
	...+>
}

This is a good idea, but it is unnecessarily inefficient in the details. You don't use the function name f, so there is no need to match the entire function. Matching the entire function causes Coccinelle to go through all of its possible control-flow paths (loops, conditional branches, etc.), which can be expensive. You can instead just start at struct device *dev = E;. Also, you don't do anything with fmt, so you can drop that, and just put ... for the remaining arguments.

Quoted 1 line

julia

I appreciate the input. I'm going to amend my script according to what you stated here. Do I have to send v2 for this patch?

Eva

#3 lore raw
Quoted 24 lines · Eva Rachel Retuya
Quoted 23 lines · Julia Lawall
Quoted 5 lines

@a@
identifier f, dev;
expression fmt, E;
@@

Quoted 9 lines
f(...) {
	...
	struct device *dev = E;
	<+... when != dev == NULL
- pr_warn(
+ dev_warn(dev,
		fmt, ...);
	...+>
}

This is a good idea, but it is unnecessarily inefficient in the details. You don't use the function name f, so there is no need to match the entire function. Matching the entire function causes Coccinelle to go through all of its possible control-flow paths (loops, conditional branches, etc.), which can be expensive. You can instead just start at struct device *dev = E;. Also, you don't do anything with fmt, so you can drop that, and just put ... for the remaining arguments.

Quoted 4 lines
Quoted 1 line

julia

I appreciate the input. I'm going to amend my script according to what you stated here. Do I have to send v2 for this patch?

Yes, please. It would be better to have better semantic patches in the git history, for people to be inspired from :)

thanks,
julia