Skip to contentSkip to conversation

staging: Thunderbolt: ctl.c style coding issues

PATCH In review Gabriel Viso Carrera 3 participants 8 messages Jun 25, 2022 – Jun 29, 2022

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

This patch set solves all coding style issues found in ctl.c, as per checkpatch.pl

[PATCH 1/3] staging: Thunderbolt: ctl.c: Fixed 2 literal style coding [PATCH 2/3] staging: Thunderbolt: ctl.c: Fixed blank line coding [PATCH 3/3] staging: Thunderbolt: ctl.c: Fixed comment coding style

#1 lore raw

PATCH 1/3 staging: Thunderbolt: ctl.c: Fixed 2 literal style coding issues

In lines 1028 and 1054, there were WARN calls with hardcoded literal function name. Replaced with the recommended %s and __func__.

---
 drivers/thunderbolt/ctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thunderbolt/ctl.c +2 -2
index e92c658dba1c..4b841fbb3628 100644
@@ -1025,7 +1025,7 @@ int tb_cfg_read(struct tb_ctl *ctl, void *buffer, u64 route, u32 port,
 		break;
 
 	default:
-		WARN(1, "tb_cfg_read: %d\n", res.err);
+		WARN(1, "%s: %d\n", __func__, res.err);
 		break;
 	}
 	return res.err;
@@ -1051,7 +1051,7 @@ int tb_cfg_write(struct tb_ctl *ctl, const void *buffer, u64 route, u32 port,
 		break;
 
 	default:
-		WARN(1, "tb_cfg_write: %d\n", res.err);
+		WARN(1, "%s: %d\n", __func__, res.err);
 		break;
 	}
 	return res.err;
Signature · 1 line
2.36.1
#2 lore raw

PATCH 2/3 staging: Thunderbolt: ctl.c: Fixed blank line coding style issues

In reply to Gabriel Viso Carrera

Added blank lines after variable declarations as per checkpatch.pl (all issues of that kind in the file).

---
 drivers/thunderbolt/ctl.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/thunderbolt/ctl.c +6 -0
index 4b841fbb3628..6c973fdf7b36 100644
@@ -232,6 +232,7 @@ static struct tb_cfg_result decode_error(const struct ctl_pkg *response)
 	struct cfg_error_pkg *pkg = response->buffer;
 	struct tb_ctl *ctl = response->ctl;
 	struct tb_cfg_result res = { 0 };
+
 	res.response_route = tb_cfg_get_route(&pkg->header);
 	res.response_port = 0;
 	res.err = check_header(response, sizeof(*pkg), TB_CFG_PKG_ERROR,
@@ -327,6 +328,7 @@ static void tb_ctl_pkg_free(struct ctl_pkg *pkg)
 static struct ctl_pkg *tb_ctl_pkg_alloc(struct tb_ctl *ctl)
 {
 	struct ctl_pkg *pkg = kzalloc(sizeof(*pkg), GFP_KERNEL);
+
 	if (!pkg)
 		return NULL;
 	pkg->ctl = ctl;
@@ -346,6 +348,7 @@ static void tb_ctl_tx_callback(struct tb_ring *ring, struct ring_frame *frame,
 			       bool canceled)
 {
 	struct ctl_pkg *pkg = container_of(frame, typeof(*pkg), frame);
+
 	tb_ctl_pkg_free(pkg);
 }
 
@@ -361,6 +364,7 @@ static int tb_ctl_tx(struct tb_ctl *ctl, const void *data, size_t len,
 {
 	int res;
 	struct ctl_pkg *pkg;
+
 	if (len % 4 != 0) { /* required for le->be conversion */
 		tb_ctl_WARN(ctl, "TX: invalid size: %zu\n", len);
 		return -EINVAL;
@@ -627,6 +631,7 @@ struct tb_ctl *tb_ctl_alloc(struct tb_nhi *nhi, int timeout_msec, event_cb cb,
 {
 	int i;
 	struct tb_ctl *ctl = kzalloc(sizeof(*ctl), GFP_KERNEL);
+
 	if (!ctl)
 		return NULL;
 	ctl->nhi = nhi;
@@ -700,6 +705,7 @@ void tb_ctl_free(struct tb_ctl *ctl)
 void tb_ctl_start(struct tb_ctl *ctl)
 {
 	int i;
+
 	tb_ctl_dbg(ctl, "control channel starting...\n");
 	tb_ring_start(ctl->tx); /* is used to ack hotplug packets, start first */
 	tb_ring_start(ctl->rx);
Signature · 1 line
2.36.1
#3 lore raw

PATCH 3/3 staging: Thunderbolt: ctl.c: Fixed comment coding style issues

In reply to Gabriel Viso Carrera

Fixed a couple of comment aligment & formatting coding style issues.

---
 drivers/thunderbolt/ctl.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/thunderbolt/ctl.c +7 -6
index 6c973fdf7b36..5c6c62867b9c 100644
@@ -276,7 +276,8 @@ static void tb_cfg_print_error(struct tb_ctl *ctl,
 	switch (res->tb_error) {
 	case TB_CFG_ERROR_PORT_NOT_CONNECTED:
 		/* Port is not connected. This can happen during surprise
-		 * removal. Do not warn. */
+		 * removal. Do not warn.
+		 */
 		return;
 	case TB_CFG_ERROR_INVALID_CONFIG_SPACE:
 		/*
@@ -402,11 +403,11 @@ static bool tb_ctl_handle_event(struct tb_ctl *ctl, enum tb_cfg_pkg_type type,
 static void tb_ctl_rx_submit(struct ctl_pkg *pkg)
 {
 	tb_ring_rx(pkg->ctl->rx, &pkg->frame); /*
-					     * We ignore failures during stop.
-					     * All rx packets are referenced
-					     * from ctl->rx_packets, so we do
-					     * not loose them.
-					     */
+						* We ignore failures during stop.
+						* All rx packets are referenced
+						* from ctl->rx_packets, so we do
+						* not loose them.
+						*/
 }
 
 static int tb_async_error(const struct ctl_pkg *pkg)
Signature · 1 line
2.36.1
#4 lore raw

Re: [PATCH 3/3] staging: Thunderbolt: ctl.c: Fixed comment coding style issues

Quoted 1 line · Gabriel Viso Carrera

Fixed a couple of comment aligment & formatting coding style issues.

trivia:

drivers/thunderbolt/ctl.c

Quoted 1 line
drivers/thunderbolt/ctl.c +0 -0

[]

Quoted 4 lines
drivers/thunderbolt/ctl.c +0 -0
@@ -402,11 +403,11 @@ static bool tb_ctl_handle_event(struct tb_ctl *ctl, enum tb_cfg_pkg_type type,
 static void tb_ctl_rx_submit(struct ctl_pkg *pkg)
 {
 	tb_ring_rx(pkg->ctl->rx, &pkg->frame); /*

drivers/thunderbolt/ctl.c static bool tb_ctl_handle_event(struct tb_ctl *ctl, enum tb_cfg_pkg_type type, · line 410

Quoted 10 lines
drivers/thunderbolt/ctl.c +5 -5
-					     * We ignore failures during stop.
-					     * All rx packets are referenced
-					     * from ctl->rx_packets, so we do
-					     * not loose them.
-					     */
+						* We ignore failures during stop.
+						* All rx packets are referenced
+						* from ctl->rx_packets, so we do
+						* not loose them.
+						*/

I'd indent this only 1 level and put it before the call (and fix the loose/lose typo)

{
	/* We ignore failures during stop.
	 * All rx packets are referenced from ctl->rx_packets,
	 * so we do not lose them.
	 */
	tb_ring_rx(pkg->ctl->rx, &pkg->frame);
}
#5 lore raw

Re: [PATCH 3/3] staging: Thunderbolt: ctl.c: Fixed comment coding style issues

On Sat, Jun 25, 2022 at 02:37:54AM -0700, Joe Perches wrote:
[]

Quoted 4 lines

I'd indent this only 1 level and put it before the call (and fix the loose/lose typo)

Quoted 8 lines
{
	/* We ignore failures during stop.
	 * All rx packets are referenced from ctl->rx_packets,
	 * so we do not lose them.
	 */
	tb_ring_rx(pkg->ctl->rx, &pkg->frame);
}

Fair enough. Not sure on how to proceed, as these were my first patches ever sent, and I don't want to make anyone work more than the strictly necessary.

- Should I submit an additional patch intended to be applied on top of 3/3?
- Should I sumbit a whole new 3/3, addressing the whole comment issues all at once?
- Should I just wait on the outcome and proceed from there?

Advice would be appreciated.

Anyway, I will be sending some patches over other files for the time being, paying more attention to the details.

Thanks,
~Gabriel

#6 lore raw

Re: [PATCH 3/3] staging: Thunderbolt: ctl.c: Fixed comment coding style issues

Quoted 15 lines · Gabriel Viso Carrera

On Sat, Jun 25, 2022 at 02:37:54AM -0700, Joe Perches wrote:
[]

Quoted 4 lines

I'd indent this only 1 level and put it before the call (and fix the loose/lose typo)

Quoted 8 lines
{
	/* We ignore failures during stop.
	 * All rx packets are referenced from ctl->rx_packets,
	 * so we do not lose them.
	 */
	tb_ring_rx(pkg->ctl->rx, &pkg->frame);
}
Quoted 3 lines

Fair enough. Not sure on how to proceed, as these were my first patches ever sent, and I don't want to make anyone work more than the strictly necessary.

If you are just learning how to do all of this, I strongly recommend you stick to drivers/staging/* which is much more forgiving and welcoming for basic coding style cleanups. After you get some experience there, then go out into other subsystems. Many subsystems do not like coding style fixes as it causes conflicts with other development that is happening.

thanks,

greg k-h

#7 lore raw

Re: [PATCH 3/3] staging: Thunderbolt: ctl.c: Fixed comment coding style issues

Quoted 10 lines · Greg KH

If you are just learning how to do all of this, I strongly recommend you stick to drivers/staging/* which is much more forgiving and welcoming for basic coding style cleanups. After you get some experience there, then go out into other subsystems. Many subsystems do not like coding style fixes as it causes conflicts with other development that is happening.

thanks,

greg k-h

I am doing these patches as my first step, yes.
Will do as suggested, thanks for that.

~Gabriel