On Thu, Jun 13, 2024 at 07:20:32PM +0100, Ben Walsh wrote: > > Dan Carpenter <dan.carpenter@xxxxxxxxxx> writes: > > > On Thu, Jun 13, 2024 at 05:51:39PM +0100, Ben Walsh wrote: > >> > >> Thanks for fixing this! Unfortunately `in_range` returns -EINVAL if > >> length == 0 (see the definition of `fwk_ec_lpc_mec_in_range`). I'm sure > >> this broke something in my testing, but I can't find what it was now. > > > > I don't think fwk_ec_lpc_mec_in_range() is upstream. This email is the > > only reference I can find to it on the internet. > > Sorry, I mean cros_ec_lpc_mec_in_range(). > > > int cros_ec_lpc_mec_in_range(unsigned int offset, unsigned int length) > > { > > if (length == 0) > > - return -EINVAL; > > + return 0; > > > > if (WARN_ON(mec_emi_base == 0 || mec_emi_end == 0)) > > return -EINVAL; > > > > But I don't like how subtle that is. Probably adding a check for > > for if (length == 0) to the to cros_ec_lpc_mec_read_bytes() seems > > like the best option. I guess option 2 is the best option. > > Thanks. I'll check out Tzung-Bi's suggestions as well before we decide. Writing length 0 bytes to cros_ec_lpc_io_bytes_mec() changes the function to basically this: cros_ec_lpc_mec_lock(); /* Initialize I/O at desired address */ cros_ec_lpc_mec_emi_write_address(offset, access); cros_ec_lpc_mec_unlock(); return 0; I was a little concerned about the cros_ec_lpc_mec_emi_write_address() But I don't know this subsystem at all so it might be fine. Perhaps the cleanest thing is to delete the length == 0 check in cros_ec_lpc_mec_in_range() and add one to the start of cros_ec_lpc_io_bytes_mec(). I think that's a good solution. regards, dan carpenter