Re: [PATCH v7 5/7] drivers/i2c: Add transfer implementation for FSI algorithm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 05/29/2018 07:08 PM, Andy Shevchenko wrote:
On Wed, May 30, 2018 at 1:24 AM, Eddie James <eajames@xxxxxxxxxxxxxxxxxx> wrote:
From: "Edward A. James" <eajames@xxxxxxxxxx>

Execute I2C transfers from the FSI-attached I2C master. Use polling
instead of interrupts as we have no hardware IRQ over FSI.
+       if (msg->flags & I2C_M_RD)
+               cmd |= I2C_CMD_READ;
I think we have a helper for this, though not sure.

Didn't see any other I2C drivers using any helper for msg->flags.


+static int fsi_i2c_write_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg,
+                             u8 fifo_count)
+{
+       int write;
+       int rc = 0;
Redundant assignment.

+       struct fsi_i2c_master *i2c = port->master;
+       int bytes_to_write = i2c->fifo_size - fifo_count;
+       int bytes_remaining = msg->len - port->xfrd;
+       if (bytes_to_write > bytes_remaining)
+               bytes_to_write = bytes_remaining;
_write = min(_write, _remaining);

+       while (bytes_to_write > 0) {
+               write = bytes_to_write;
+               /* fsi limited to max 4 byte aligned ops */
+               if (bytes_to_write > 4)
+                       write = 4;
+               else if (write == 3)
+                       write = 2;
write = min_t(int, 4, rounddown_pow_of_two(bytes_to_write));

Also check it carefully, it might be optimized even more, though I
didn't think much.

I think it is more readable this way, and I'm not convinced the min(rounddown()) is faster. I did however add a common function to do this check since it's performed in both the read and write fifo functions. Let me know what you think on v8.

Thanks,
Eddie

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux