Skip to contentSkip to conversation

drivers: fsi: Copy all data out

PATCH Superseded Eddie James 3 participants 3 messages Feb 20, 2017 1 message not in the archive FSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: fsi: Copy all data out

From: "Edward A. James" <[email protected]>

Driver was only copying 32 bits out to the user-provided data pointer.

---
 drivers/fsi/fsi-master-gpio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/fsi/fsi-master-gpio.c +3 -2
index 3ed82ea..3eb6ec2 100644
@@ -203,7 +203,7 @@ static void fsi_master_gpio_error(struct fsi_master_gpio *master, int error)
 static int poll_for_response(struct fsi_master_gpio *master, uint8_t expected,
 			uint8_t size, void *data)
 {
-	int busy_count = 0, i;
+	int busy_count = 0, i, j;
 	struct fsi_gpio_msg response, cmd;
 	int bits_remaining = 0, bit_count, response_id, id;
 	uint64_t resp = 0;
@@ -274,7 +274,8 @@ static int poll_for_response(struct fsi_master_gpio *master, uint8_t expected,
 			resp <<= bits_remaining;
 			resp |= response.msg;
 			bits_received += bits_remaining;
-			*((uint32_t *)data) = response.msg;
+			for (j = 0; j < size; ++j)
+				((uint8_t *)data)[j] = ((uint8_t *)&response.msg)[j];
 		}
 
 		crc_in = fsi_crc4(0, resp | (0x1ULL << bits_received),
Signature · 1 line
1.8.3.1
#1 lore raw

-----"openbmc" <[email protected]> wrote: -----

Quoted 30 lines

From: Eddie James
Date: 02/20/2017 03:06PM

From: "Edward A. James" <[email protected]>

Driver was only copying 32 bits out to the user-provided data pointer.

---
drivers/fsi/fsi-master-gpio.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
drivers/fsi/fsi-master-gpio.c +0 -0
index 3ed82ea..3eb6ec2 100644
@@ -203,7 +203,7 @@ static void fsi_master_gpio_error(struct
 fsi_master_gpio *master, int error)

static int poll_for_response(struct fsi_master_gpio *master, uint8_t expected,
uint8_t size, void *data)
{

drivers/fsi/fsi-master-gpio.c +1 -1
-	int busy_count = 0, i;
+	int busy_count = 0, i, j;
	struct fsi_gpio_msg response, cmd;
	int bits_remaining = 0, bit_count, response_id, id;
	uint64_t resp = 0;

drivers/fsi/fsi-master-gpio.c static int poll_for_response(struct · line 279

Quoted 7 lines
drivers/fsi/fsi-master-gpio.c +2 -1
@@ -274,7 +274,8 @@ static int poll_for_response(struct
 fsi_master_gpio *master, uint8_t expected,
 			resp <<= bits_remaining;
 			resp |= response.msg;
 			bits_received += bits_remaining;
-			*((uint32_t *)data) = response.msg;
+			for (j = 0; j < size; ++j)
+				((uint8_t *)data)[j] = ((uint8_t *)&response.msg)[j];

A lot of casting for memcpy(data, &response.msg, size);

Quoted 5 lines
drivers/fsi/fsi-master-gpio.c +0 -0
 		}
 
		crc_in = fsi_crc4(0, resp | (0x1ULL << bits_received),
Signature · 1 line
1.8.3.1

milton

A message that is not in the archive (sent off-list or not yet received): OF7EE21505.D63A2F41-ON002580CD.007BE8A7-002580CD.007BE8AB@LocalDomain

#3 lore raw

Milton Miller II/Austin/IBM wrote on 02/20/2017 04:33:24 PM:

Quoted 3 lines

From: Milton Miller II/Austin/IBM
To: Eddie James <[email protected]>
Cc: [email protected], [email protected], Edward

James/Austin/IBM@IBMUS

Quoted 38 lines

Date: 02/20/2017 04:33 PM
Subject: Re: [PATCH linux dev-4.7] drivers: fsi: Copy all data out

-----"openbmc" <[email protected]>
wrote: -----

Quoted 31 lines

From: Eddie James
Date: 02/20/2017 03:06PM

From: "Edward A. James" <[email protected]>

Driver was only copying 32 bits out to the user-provided data pointer.

---
drivers/fsi/fsi-master-gpio.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
drivers/fsi/fsi-master-gpio.c +0 -0
index 3ed82ea..3eb6ec2 100644
@@ -203,7 +203,7 @@ static void fsi_master_gpio_error(struct
 fsi_master_gpio *master, int error)

static int poll_for_response(struct fsi_master_gpio *master, uint8_t expected,
uint8_t size, void *data)
{

drivers/fsi/fsi-master-gpio.c +1 -1
-   int busy_count = 0, i;
+   int busy_count = 0, i, j;
   struct fsi_gpio_msg response, cmd;
   int bits_remaining = 0, bit_count, response_id, id;
   uint64_t resp = 0;
@@ -274,7 +274,8 @@ static int poll_for_response(struct
 fsi_master_gpio *master, uint8_t expected,
Quoted 8 lines

drivers/fsi/fsi-master-gpio.c static int poll_for_response(struct fsi_master_gpio *master, uint8_t expected, · line 278

Quoted 6 lines
drivers/fsi/fsi-master-gpio.c +2 -1
         resp <<= bits_remaining;
         resp |= response.msg;
         bits_received += bits_remaining;
-         *((uint32_t *)data) = response.msg;
+         for (j = 0; j < size; ++j)
+            ((uint8_t *)data)[j] = ((uint8_t *)&response.msg)[j];

A lot of casting for memcpy(data, &response.msg, size);

Ugh, thanks. I was experimenting switching the byte order and didn't switch it back to something sensible... v2 on the way.

Eddie

Quoted 8 lines
Quoted 6 lines
drivers/fsi/fsi-master-gpio.c +0 -0
      }
 
      crc_in = fsi_crc4(0, resp | (0x1ULL << bits_received),

--
1.8.3.1

milton