Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: trigger: stm32-timer-trigger: make use of regmap_clear_bits(), regmap_set_bits()

Instead of using regmap_update_bits() and passing the mask twice, use
regmap_set_bits().

Instead of using regmap_update_bits() and passing val = 0, use
regmap_clear_bits().

Suggested-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20240617-review-v3-41-88d1338c4cca@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Trevor Gamblin and committed by
Jonathan Cameron
04eb9499 ac403e8c

+16 -18
+16 -18
drivers/iio/trigger/stm32-timer-trigger.c
··· 158 158 159 159 regmap_write(priv->regmap, TIM_PSC, prescaler); 160 160 regmap_write(priv->regmap, TIM_ARR, prd - 1); 161 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, TIM_CR1_ARPE); 161 + regmap_set_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE); 162 162 163 163 /* Force master mode to update mode */ 164 164 if (stm32_timer_is_trgo2_name(trig->name)) ··· 169 169 0x2 << TIM_CR2_MMS_SHIFT); 170 170 171 171 /* Make sure that registers are updated */ 172 - regmap_update_bits(priv->regmap, TIM_EGR, TIM_EGR_UG, TIM_EGR_UG); 172 + regmap_set_bits(priv->regmap, TIM_EGR, TIM_EGR_UG); 173 173 174 174 /* Enable controller */ 175 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, TIM_CR1_CEN); 175 + regmap_set_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN); 176 176 mutex_unlock(&priv->lock); 177 177 178 178 return 0; ··· 189 189 190 190 mutex_lock(&priv->lock); 191 191 /* Stop timer */ 192 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0); 193 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0); 192 + regmap_clear_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE); 193 + regmap_clear_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN); 194 194 regmap_write(priv->regmap, TIM_PSC, 0); 195 195 regmap_write(priv->regmap, TIM_ARR, 0); 196 196 197 197 /* Force disable master mode */ 198 198 if (stm32_timer_is_trgo2_name(trig->name)) 199 - regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2, 0); 199 + regmap_clear_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2); 200 200 else 201 - regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS, 0); 201 + regmap_clear_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS); 202 202 203 203 /* Make sure that registers are updated */ 204 - regmap_update_bits(priv->regmap, TIM_EGR, TIM_EGR_UG, TIM_EGR_UG); 204 + regmap_set_bits(priv->regmap, TIM_EGR, TIM_EGR_UG); 205 205 206 206 if (priv->enabled) { 207 207 priv->enabled = false; ··· 498 498 priv->enabled = true; 499 499 clk_enable(priv->clk); 500 500 } 501 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 502 - TIM_CR1_CEN); 501 + regmap_set_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN); 503 502 } else { 504 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 505 - 0); 503 + regmap_clear_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN); 506 504 if (priv->enabled) { 507 505 priv->enabled = false; 508 506 clk_disable(priv->clk); ··· 553 555 { 554 556 struct stm32_timer_trigger *priv = iio_priv(indio_dev); 555 557 556 - regmap_update_bits(priv->regmap, TIM_SMCR, TIM_SMCR_SMS, TIM_SMCR_SMS); 558 + regmap_set_bits(priv->regmap, TIM_SMCR, TIM_SMCR_SMS); 557 559 558 560 return 0; 559 561 } ··· 681 683 return ret; 682 684 683 685 /* TIMx_ARR register shouldn't be buffered (ARPE=0) */ 684 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0); 686 + regmap_clear_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE); 685 687 regmap_write(priv->regmap, TIM_ARR, preset); 686 688 687 689 return len; ··· 755 757 * Master mode selection 2 bits can only be written and read back when 756 758 * timer supports it. 757 759 */ 758 - regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2, TIM_CR2_MMS2); 760 + regmap_set_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2); 759 761 regmap_read(priv->regmap, TIM_CR2, &val); 760 - regmap_update_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2, 0); 762 + regmap_clear_bits(priv->regmap, TIM_CR2, TIM_CR2_MMS2); 761 763 priv->has_trgo2 = !!val; 762 764 } 763 765 ··· 818 820 /* Check if nobody else use the timer, then disable it */ 819 821 regmap_read(priv->regmap, TIM_CCER, &val); 820 822 if (!(val & TIM_CCER_CCXE)) 821 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0); 823 + regmap_clear_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN); 822 824 823 825 if (priv->enabled) 824 826 clk_disable(priv->clk); ··· 839 841 regmap_read(priv->regmap, TIM_SMCR, &priv->bak.smcr); 840 842 841 843 /* Disable the timer */ 842 - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0); 844 + regmap_clear_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN); 843 845 clk_disable(priv->clk); 844 846 } 845 847