2022-06-11 16:26:28

by Vincent MAILHOL

[permalink] [raw]
Subject: [PATCH 0/2] can: etas_es58x: cleanups on struct es58x_device

This series contains two clean up patches toward struct es58x_device
of the CAN etas_es58x driver. The first one removes the field
rx_max_packet_size which value can actually be retrieved from the
helper function usb_maxpacket(). The second one fixes the signedness
of the TX and RX pipes.

No functional changes.

Vincent Mailhol (2):
can: etas_es58x: replace es58x_device::rx_max_packet_size by
usb_maxpacket()
can: etas_es58x: fix signedness of USB RX and TX pipes

drivers/net/can/usb/etas_es58x/es58x_core.c | 5 ++---
drivers/net/can/usb/etas_es58x/es58x_core.h | 6 ++----
2 files changed, 4 insertions(+), 7 deletions(-)

--
2.35.1


2022-06-11 16:35:07

by Vincent MAILHOL

[permalink] [raw]
Subject: [PATCH 1/2] can: etas_es58x: replace es58x_device::rx_max_packet_size by usb_maxpacket()

The field rx_max_packet_size of struct es58x_device in nothing else
than usb_endpoint_descriptor::wMaxPacketSize and can be easily
retrieved using usb_maxpacket(). Also, rx_max_packet_size being used a
single time, there is no merit to cache it locally.

Remove es58x_device::rx_max_packet_size and rely on usb_maxpacket()
instead.

Signed-off-by: Vincent Mailhol <[email protected]>
---
drivers/net/can/usb/etas_es58x/es58x_core.c | 5 ++---
drivers/net/can/usb/etas_es58x/es58x_core.h | 2 --
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c
index 2d73ebbf3836..7353745f92d7 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -1707,7 +1707,7 @@ static int es58x_alloc_rx_urbs(struct es58x_device *es58x_dev)
{
const struct device *dev = es58x_dev->dev;
const struct es58x_parameters *param = es58x_dev->param;
- size_t rx_buf_len = es58x_dev->rx_max_packet_size;
+ u16 rx_buf_len = usb_maxpacket(es58x_dev->udev, es58x_dev->rx_pipe);
struct urb *urb;
u8 *buf;
int i;
@@ -1739,7 +1739,7 @@ static int es58x_alloc_rx_urbs(struct es58x_device *es58x_dev)
dev_err(dev, "%s: Could not setup any rx URBs\n", __func__);
return ret;
}
- dev_dbg(dev, "%s: Allocated %d rx URBs each of size %zu\n",
+ dev_dbg(dev, "%s: Allocated %d rx URBs each of size %u\n",
__func__, i, rx_buf_len);

return ret;
@@ -2223,7 +2223,6 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf,
ep_in->bEndpointAddress);
es58x_dev->tx_pipe = usb_sndbulkpipe(es58x_dev->udev,
ep_out->bEndpointAddress);
- es58x_dev->rx_max_packet_size = le16_to_cpu(ep_in->wMaxPacketSize);

return es58x_dev;
}
diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index e5033cb5e695..512c5b7a1cfa 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -380,7 +380,6 @@ struct es58x_operators {
* @timestamps: a temporary buffer to store the time stamps before
* feeding them to es58x_can_get_echo_skb(). Can only be used
* in RX branches.
- * @rx_max_packet_size: Maximum length of bulk-in URB.
* @num_can_ch: Number of CAN channel (i.e. number of elements of @netdev).
* @opened_channel_cnt: number of channels opened. Free of race
* conditions because its two users (net_device_ops:ndo_open()
@@ -414,7 +413,6 @@ struct es58x_device {

u64 timestamps[ES58X_ECHO_BULK_MAX];

- u16 rx_max_packet_size;
u8 num_can_ch;
u8 opened_channel_cnt;

--
2.35.1

2022-06-11 17:12:25

by Vincent MAILHOL

[permalink] [raw]
Subject: [PATCH 2/2] can: etas_es58x: fix signedness of USB RX and TX pipes

USB pipes are meant to be unsigned int (c.f. [1]). However, fields
rx_pipe and tx_pipe of struct es58x_device are both signed
integers. Change the type of those two fields from int to unsigned
int.

[1] https://elixir.bootlin.com/linux/v5.18/source/include/linux/usb.h#L1571

Signed-off-by: Vincent Mailhol <[email protected]>
---
drivers/net/can/usb/etas_es58x/es58x_core.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h
index 512c5b7a1cfa..d769bdf740b7 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.h
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.h
@@ -400,8 +400,8 @@ struct es58x_device {
const struct es58x_parameters *param;
const struct es58x_operators *ops;

- int rx_pipe;
- int tx_pipe;
+ unsigned int rx_pipe;
+ unsigned int tx_pipe;

struct usb_anchor rx_urbs;
struct usb_anchor tx_urbs_busy;
--
2.35.1

2022-06-11 22:35:20

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH 0/2] can: etas_es58x: cleanups on struct es58x_device

On 12.06.2022 01:20:35, Vincent Mailhol wrote:
> This series contains two clean up patches toward struct es58x_device
> of the CAN etas_es58x driver. The first one removes the field
> rx_max_packet_size which value can actually be retrieved from the
> helper function usb_maxpacket(). The second one fixes the signedness
> of the TX and RX pipes.
>
> No functional changes.

Applied to linux-can-next/testing.

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |


Attachments:
(No filename) (700.00 B)
signature.asc (499.00 B)
Download all attachments