Skip to content

Commit f88c0c7

Browse files
jwrdegoedegregkh
authored andcommitted
mei: vsc: Use struct vsc_tp_packet as vsc-tp tx_buf and rx_buf type
vsc_tp.tx_buf and vsc_tp.rx_buf point to a struct vsc_tp_packet, use the correct type instead of "void *" and use sizeof(*ptr) when allocating memory for these buffers. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Alexander Usyskin <alexander.usyskin@intel.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Link: https://lore.kernel.org/r/20250318141203.94342-3-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 00f1cc1 commit f88c0c7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/misc/mei/vsc-tp.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ struct vsc_tp {
7171
u32 seq;
7272

7373
/* command buffer */
74-
void *tx_buf;
75-
void *rx_buf;
74+
struct vsc_tp_packet *tx_buf;
75+
struct vsc_tp_packet *rx_buf;
7676

7777
atomic_t assert_cnt;
7878
wait_queue_head_t xfer_wait;
@@ -164,7 +164,7 @@ static int vsc_tp_xfer_helper(struct vsc_tp *tp, struct vsc_tp_packet *pkt,
164164
{
165165
int ret, offset = 0, cpy_len, src_len, dst_len = sizeof(struct vsc_tp_packet_hdr);
166166
int next_xfer_len = VSC_TP_PACKET_SIZE(pkt) + VSC_TP_XFER_TIMEOUT_BYTES;
167-
u8 *src, *crc_src, *rx_buf = tp->rx_buf;
167+
u8 *src, *crc_src, *rx_buf = (u8 *)tp->rx_buf;
168168
int count_down = VSC_TP_MAX_XFER_COUNT;
169169
u32 recv_crc = 0, crc = ~0;
170170
struct vsc_tp_packet_hdr ack;
@@ -324,7 +324,7 @@ int vsc_tp_rom_xfer(struct vsc_tp *tp, const void *obuf, void *ibuf, size_t len)
324324
guard(mutex)(&tp->mutex);
325325

326326
/* rom xfer is big endian */
327-
cpu_to_be32_array(tp->tx_buf, obuf, words);
327+
cpu_to_be32_array((u32 *)tp->tx_buf, obuf, words);
328328

329329
ret = read_poll_timeout(gpiod_get_value_cansleep, ret,
330330
!ret, VSC_TP_ROM_XFER_POLL_DELAY_US,
@@ -340,7 +340,7 @@ int vsc_tp_rom_xfer(struct vsc_tp *tp, const void *obuf, void *ibuf, size_t len)
340340
return ret;
341341

342342
if (ibuf)
343-
be32_to_cpu_array(ibuf, tp->rx_buf, words);
343+
be32_to_cpu_array(ibuf, (u32 *)tp->rx_buf, words);
344344

345345
return ret;
346346
}
@@ -494,11 +494,11 @@ static int vsc_tp_probe(struct spi_device *spi)
494494
if (!tp)
495495
return -ENOMEM;
496496

497-
tp->tx_buf = devm_kzalloc(dev, VSC_TP_MAX_XFER_SIZE, GFP_KERNEL);
497+
tp->tx_buf = devm_kzalloc(dev, sizeof(*tp->tx_buf), GFP_KERNEL);
498498
if (!tp->tx_buf)
499499
return -ENOMEM;
500500

501-
tp->rx_buf = devm_kzalloc(dev, VSC_TP_MAX_XFER_SIZE, GFP_KERNEL);
501+
tp->rx_buf = devm_kzalloc(dev, sizeof(*tp->rx_buf), GFP_KERNEL);
502502
if (!tp->rx_buf)
503503
return -ENOMEM;
504504

0 commit comments

Comments
 (0)