diff mbox series

[2/3] hw/p8-i2c: Remove p8_i2c_request structure

Message ID 20180823034732.2467-2-oohall@gmail.com
State Accepted
Headers show
Series [1/3] core/i2c: Move the timeout field into i2c_request | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Oliver O'Halloran Aug. 23, 2018, 3:47 a.m. UTC
The p8_i2c_request structure is barely used and the only useful data it
contains (port_num) can be derived from the bus pointer. Remove it in
preperation for removing the per-bus allocation and free methods.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hw/p8-i2c.c | 34 +++-------------------------------
 1 file changed, 3 insertions(+), 31 deletions(-)
diff mbox series

Patch

diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c
index d3b383514186..67a68cd2a6df 100644
--- a/hw/p8-i2c.c
+++ b/hw/p8-i2c.c
@@ -229,15 +229,8 @@  struct p8_i2c_master_port {
 	struct list_node	link;
 };
 
-struct p8_i2c_request {
-	struct i2c_request	req;
-	uint32_t		port_num;
-	uint64_t		timeout;
-};
-
 static int occ_i2c_unlock(struct p8_i2c_master *master);
 
-
 static int64_t i2cm_read_reg(struct p8_i2c_master *m, int reg, uint64_t *val)
 {
 	return xscom_read(m->chip_id, m->xscom_base + reg, val);
@@ -410,10 +403,6 @@  static int p8_i2c_prog_watermark(struct p8_i2c_master *master)
 static int p8_i2c_prog_mode(struct p8_i2c_master_port *port, bool enhanced_mode)
 {
 	struct p8_i2c_master *master = port->master;
-	struct i2c_request *req = list_top(&master->req_list,
-					   struct i2c_request, link);
-	struct p8_i2c_request *request =
-		container_of(req, struct p8_i2c_request, req);
 	uint64_t mode, omode;
 	int rc;
 
@@ -424,7 +413,7 @@  static int p8_i2c_prog_mode(struct p8_i2c_master_port *port, bool enhanced_mode)
 		return rc;
 	}
 	omode = mode;
-	mode = SETFIELD(I2C_MODE_PORT_NUM, mode, request->port_num);
+	mode = SETFIELD(I2C_MODE_PORT_NUM, mode, port->port_num);
 	mode = SETFIELD(I2C_MODE_BIT_RATE_DIV, mode, port->bit_rate_div);
 	if (enhanced_mode)
 		mode |= I2C_MODE_ENHANCED;
@@ -1282,29 +1271,12 @@  static int p8_i2c_queue_request(struct i2c_request *req)
 
 static struct i2c_request *p8_i2c_alloc_request(struct i2c_bus *bus)
 {
-	struct p8_i2c_master_port *port =
-		container_of(bus, struct p8_i2c_master_port, bus);
-	struct p8_i2c_request *request;
-
-	request = zalloc(sizeof(*request));
-	if (!request) {
-		prlog(PR_ERR, "I2C: Failed to allocate i2c request\n");
-		return NULL;
-	}
-
-	request->port_num = port->port_num;
-	request->req.bus = bus;
-
-	return &request->req;
+	return zalloc(sizeof(struct i2c_request));
 }
-
 static void p8_i2c_free_request(struct i2c_request *req)
 {
-	struct p8_i2c_request *request =
-		container_of(req, struct p8_i2c_request, req);
-	free(request);
+	free(req);
 }
-
 static uint64_t p8_i2c_run_request(struct i2c_request *req)
 {
 	struct i2c_bus *bus = req->bus;