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.

i2c: designware-platdrv: simplify reset control

The current implementation uses separate calls to acquire and deassert
reset control, requiring manual error handling for the deassertion
operation. This can be simplified using the dedicated devm function that
combines both operations.

Replace devm_reset_control_get_optional_exclusive() with
devm_reset_control_get_optional_exclusive_deasserted(), which handles both
reset acquisition and deassertion in a single call as well as
reset_control_put() which is called automatically on driver detach. This
eliminates the need for explicit deassertion and its associated error
checking while maintaining the same functional behavior through automatic
resource management.

Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260130111039.874548-2-a.shimko.dev@gmail.com

authored by

Artem Shimko and committed by
Andi Shyti
78821a75 eddfdab4

+9 -21
+9 -21
drivers/i2c/busses/i2c-designware-platdrv.c
··· 160 160 if (ret) 161 161 return ret; 162 162 163 - dev->rst = devm_reset_control_get_optional_exclusive(device, NULL); 163 + dev->rst = devm_reset_control_get_optional_exclusive_deasserted(device, NULL); 164 164 if (IS_ERR(dev->rst)) 165 165 return dev_err_probe(device, PTR_ERR(dev->rst), "failed to acquire reset\n"); 166 166 167 - reset_control_deassert(dev->rst); 168 - 169 167 ret = i2c_dw_fw_parse_and_configure(dev); 170 168 if (ret) 171 - goto exit_reset; 169 + return ret; 172 170 173 171 ret = i2c_dw_probe_lock_support(dev); 174 - if (ret) { 175 - dev_err_probe(device, ret, "failed to probe lock support\n"); 176 - goto exit_reset; 177 - } 172 + if (ret) 173 + return dev_err_probe(device, ret, "failed to probe lock support\n"); 178 174 179 175 i2c_dw_configure(dev); 180 176 181 177 /* Optional interface clock */ 182 178 dev->pclk = devm_clk_get_optional(device, "pclk"); 183 - if (IS_ERR(dev->pclk)) { 184 - ret = dev_err_probe(device, PTR_ERR(dev->pclk), "failed to acquire pclk\n"); 185 - goto exit_reset; 186 - } 179 + if (IS_ERR(dev->pclk)) 180 + return dev_err_probe(device, PTR_ERR(dev->pclk), "failed to acquire pclk\n"); 187 181 188 182 dev->clk = devm_clk_get_optional(device, NULL); 189 - if (IS_ERR(dev->clk)) { 190 - ret = dev_err_probe(device, PTR_ERR(dev->clk), "failed to acquire clock\n"); 191 - goto exit_reset; 192 - } 183 + if (IS_ERR(dev->clk)) 184 + return dev_err_probe(device, PTR_ERR(dev->clk), "failed to acquire clock\n"); 193 185 194 186 ret = i2c_dw_prepare_clk(dev, true); 195 187 if (ret) 196 - goto exit_reset; 188 + return ret; 197 189 198 190 if (dev->clk) { 199 191 struct i2c_timings *t = &dev->timings; ··· 233 241 exit_probe: 234 242 dw_i2c_plat_pm_cleanup(dev); 235 243 i2c_dw_prepare_clk(dev, false); 236 - exit_reset: 237 - reset_control_assert(dev->rst); 238 244 return ret; 239 245 } 240 246 ··· 252 262 dw_i2c_plat_pm_cleanup(dev); 253 263 254 264 i2c_dw_prepare_clk(dev, false); 255 - 256 - reset_control_assert(dev->rst); 257 265 } 258 266 259 267 static const struct of_device_id dw_i2c_of_match[] = {