daniel-santos / mcp2210-linux

MCP2210 driver for linux
http://danielthesantos.blogspot.com/search/label/mcp2210
51 stars 31 forks source link

Regarding input GPIO value reading on PPC #20

Open ronakadesai opened 8 years ago

ronakadesai commented 8 years ago

Hi,

I am using this driver on PPC architecture and I observed following issue, I found the resolution also but wanted to confirm this here.

Issue : When from linux we read the input configured GPIO, it does not show correct value on powerpc architecture as it's big endian machine.

Reason : complete_cmd_chip function in the mcp2210-gpio.c file again perform the endianness conversation using following line. c->gpio_val_dir = le16_to_cpu(dev->eps[EP_IN].buffer->body.gpio);

Solution:
This is not required because already before and after submitting URBs we are doing the endianness conversion so we can use this value directly without reconverting it. So, following should be there. c->gpio_val_dir = dev->eps[EP_IN].buffer->body.gpio;

Note : On the little endian machine there won't be any impact of this even though we keep the conversion.

Please confirm my understanding.

Thanks, Ronak

daniel-santos commented 8 years ago

I very much appreciate this as I have never tested this driver on a big-endian machine! I've neglected this project quite a bit over the last year, so I want to re-test this change on the archs that I have and I suppose it would help for me to get a PPC machine of some type to test on as well.

ronakadesai commented 8 years ago

You are welcome and thank you for this driver. I have tested this fix on the little endian machine (x86) as well and it does not break anything.

daniel-santos commented 8 years ago

Being that I don't have virtual box set up right now to test this (and I don't have any PPC hardware) I'm tempted to commit this based upon your testing, but that's not usually how I like to do things. :)

daniel-santos commented 8 years ago

merged, I just need to verify that it works. I'll setup a big endian qemu guest eventually and test it before I close. Thanks for the help!