Conversation
|
checkpatch has a few pertinent complaints |
| #include <linux/sysfs.h> | ||
| #include <linux/delay.h> | ||
| #include <linux/gpio.h> | ||
| #include <linux/gpio/consumer.h> |
There was a problem hiding this comment.
I'll reference this commit f86b233 since that's where the initial comments were added.
No need to duplicate them here.
| gpiod_set_value(st->pdata->a[0], ad2s1210_mode_vals[mode][0]); | ||
| gpiod_set_value(st->pdata->a[1], ad2s1210_mode_vals[mode][1]); | ||
| st->mode = mode; | ||
| if (st->mode != MOD_CONFIG_ONLY) { |
There was a problem hiding this comment.
this is a nitpick; but another way to do it here is to exit early;
it minimizes the patch size;
so, it could be done as:
if (st->mode == MOD_CONFIG_ONLY)
return;
| return ad2s1210_resolution_value[ | ||
| (gpiod_get_value(st->pdata->res[0]) << 1) | | ||
| gpiod_get_value(st->pdata->res[1])]; | ||
| int res0 = 0; |
There was a problem hiding this comment.
this could exit early with
if (st->mode == MOD_CONFIG_ONLY)
return ad2s1210_resolution_value[0];
| int index; | ||
|
|
||
| if (st->mode != MOD_CONFIG_ONLY) { | ||
| index = (st->resolution - 10) / 2; |
There was a problem hiding this comment.
i like the caching of the calculated value here;
so, i guess this could be left as is here [with respect to exiting early, it should be fine as is];
| if (st->mode != MOD_CONFIG_ONLY) | ||
| ad2s1210_set_mode(MOD_POS, st); | ||
| else { | ||
| st->rx[0] = ad2s1210_config_read(st, |
There was a problem hiding this comment.
you could assign a reg = AD2S1210_REG_POSITION here and reg = AD2S1210_REG_VELOCITY
and do below:
if (st->mode != MOD_CONFIG_ONLY) {
ret = spi_read(st->sdev, st->rx, 2);
if (ret < 0)
goto error_ret;
} else {
st->rx[0] = ad2s1210_config_read(st, reg);
st->rx[1] = ad2s1210_config_read(st, reg + 1);
}
|
My fault - it seems that if 2 commits are pushed, checkpatch is run only on the second one... I'll do the fixes. |
|
A bit related to this series; should we merge the |
|
This is a good question. @larsclausen ? |
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| return st->rx[0]; |
There was a problem hiding this comment.
I am thinking if this can be done with a single spi_sync_transfer()?
There was a problem hiding this comment.
It can be for sure if an array of spi_transfers is used. Each xfer should be initialized in this case, so I decided to simply call spi_sync_transfer() twice.
I'm not really against any of these two options...
There was a problem hiding this comment.
A advantage of a single transfer is that it will be locked. If you split it into two transfers other devices might squeeze their own transfers in between.
There was a problem hiding this comment.
I'll do the update.
|
@dbogdan Your choice |
| return NULL; | ||
|
|
||
| pdata->gpioin = of_property_read_bool(np, | ||
| "adi,gpios-input-direction-enable"); |
There was a problem hiding this comment.
Whenever you have a DT property that ends in a verb you've lost the game. The DT is descriptive not imperative.
Think "GPIOs are wired as inputs" and not "GPIOs should be configured as inputs".
d012e80 to
72bfd03
Compare
|
v2:
|
|
v3:
|
commodo
left a comment
There was a problem hiding this comment.
LGTM
Will merge Monday or Tuesday if no objections
No functional changes. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
According to AD2S1210 datasheet, if the serial interface is used, the 8-bit address should be latched using the rising edge of the WR/FSYNC signal. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
The descriptor-based GPIO interface is a safer alternative to the legacy GPIO interface. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
The AD2S1210 can be operated entirely in configuration mode. In this mode, the only required GPIO is SAMPLE. The driver will enable MOD_CONFIG_ONLY when any of the other GPIOs is missing. AD-FMCMOTCON2-EBZ evaluation board is one example where AD2S1210 is used in this mode. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
The AD2S1210's driver will automatically enable this mode when SAMPLE is the only GPIO defined. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
CLKIN is independent of SPI SCLK. Its default value is AD2S1210_DEF_CLKIN. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
The part is installed on AD-FMCMOTCON2-EBZ evaluation board. Signed-off-by: Dragos Bogdan <dragos.bogdan@analog.com>
|
After more testing, v4 appeared. :)
|
These changes make the driver usable on AD-FMCMOTCON2-EBZ.