The 104-quad-8 driver provides support for Index signal polarity modes via the "index_polarity" Signal component. This patch exposes the same functionality through the more standard "polarity" Signal component.
Unified · Split
| @@ -549,6 +549,32 @@ static int quad8_index_polarity_set(struct counter_device *counter, · 548 unmodified lines | ||
| 549 | 549 | return 0; |
| 550 | 550 | } |
| 551 | 551 | |
| 552 | +static int quad8_polarity_read(struct counter_device *counter, | |
| 553 | + struct counter_signal *signal, | |
| 554 | + enum counter_signal_polarity *polarity) | |
| 555 | +{ | |
| 556 | + int err; | |
| 557 | + u32 index_polarity; | |
| 558 | + | |
| 559 | + err = quad8_index_polarity_get(counter, signal, &index_polarity); | |
| 560 | + if (err) | |
| 561 | + return err; | |
| 562 | + | |
| 563 | + *polarity = (index_polarity) ? COUNTER_SIGNAL_POLARITY_POSITIVE : | |
| 564 | + COUNTER_SIGNAL_POLARITY_NEGATIVE; | |
| 565 | + | |
| 566 | + return 0; | |
| 567 | +} | |
| 568 | + | |
| 569 | +static int quad8_polarity_write(struct counter_device *counter, | |
| 570 | + struct counter_signal *signal, | |
| 571 | + enum counter_signal_polarity polarity) | |
| 572 | +{ | |
| 573 | + const u32 pol = (polarity == COUNTER_SIGNAL_POLARITY_POSITIVE) ? 1 : 0; | |
| 574 | + | |
| 575 | + return quad8_index_polarity_set(counter, signal, pol); | |
| 576 | +} | |
| 577 | + | |
| 552 | 578 | static const char *const quad8_synchronous_modes[] = { |
| 553 | 579 | "non-synchronous", |
| 554 | 580 | "synchronous" |
| @@ -977,6 +1003,13 @@ static struct counter_comp quad8_signal_ext[] = { · 422 unmodified lines | ||
| 977 | 1003 | quad8_signal_fck_prescaler_write) |
| 978 | 1004 | }; |
| 979 | 1005 | |
| 1006 | +static const enum counter_signal_polarity quad8_polarities[] = { | |
| 1007 | + COUNTER_SIGNAL_POLARITY_POSITIVE, | |
| 1008 | + COUNTER_SIGNAL_POLARITY_NEGATIVE, | |
| 1009 | +}; | |
| 1010 | + | |
| 1011 | +static DEFINE_COUNTER_AVAILABLE(quad8_polarity_available, quad8_polarities); | |
| 1012 | + | |
| 980 | 1013 | static DEFINE_COUNTER_ENUM(quad8_index_pol_enum, quad8_index_polarity_modes); |
| 981 | 1014 | static DEFINE_COUNTER_ENUM(quad8_synch_mode_enum, quad8_synchronous_modes); |
| 982 | 1015 | |
| @@ -984,6 +1017,8 @@ static struct counter_comp quad8_index_ext[] = { · 1 unmodified line | ||
| 984 | 1017 | COUNTER_COMP_SIGNAL_ENUM("index_polarity", quad8_index_polarity_get, |
| 985 | 1018 | quad8_index_polarity_set, |
| 986 | 1019 | quad8_index_pol_enum), |
| 1020 | + COUNTER_COMP_POLARITY(quad8_polarity_read, quad8_polarity_write, | |
| 1021 | + quad8_polarity_available), | |
| 987 | 1022 | COUNTER_COMP_SIGNAL_ENUM("synchronous_mode", quad8_synchronous_mode_get, |
| 988 | 1023 | quad8_synchronous_mode_set, |
| 989 | 1024 | quad8_synch_mode_enum), |