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: spacemit: move i2c_xfer_msg()

The upcoming PIO support requires a wait_pio_xfer() helper, which is
invoked from xfer_msg().

Since wait_pio_xfer() depends on err_check(), move the definition of
xfer_msg() after err_check() to avoid a forward declaration of
err_check().

Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Reviewed-by: Alex Elder <elder@riscstar.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Tested-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20260207-b4-k3-i2c-pio-v7-1-626942d94d91@linux.spacemit.com

authored by

Troy Mitchell and committed by
Andi Shyti
5b74da8e dd0422eb

+31 -31
+31 -31
drivers/i2c/busses/i2c-k1.c
··· 305 305 writel(val, i2c->base + SPACEMIT_ICR); 306 306 } 307 307 308 - static int spacemit_i2c_xfer_msg(struct spacemit_i2c_dev *i2c) 309 - { 310 - unsigned long time_left; 311 - struct i2c_msg *msg; 312 - 313 - for (i2c->msg_idx = 0; i2c->msg_idx < i2c->msg_num; i2c->msg_idx++) { 314 - msg = &i2c->msgs[i2c->msg_idx]; 315 - i2c->msg_buf = msg->buf; 316 - i2c->unprocessed = msg->len; 317 - i2c->status = 0; 318 - 319 - reinit_completion(&i2c->complete); 320 - 321 - spacemit_i2c_start(i2c); 322 - 323 - time_left = wait_for_completion_timeout(&i2c->complete, 324 - i2c->adapt.timeout); 325 - if (!time_left) { 326 - dev_err(i2c->dev, "msg completion timeout\n"); 327 - spacemit_i2c_conditionally_reset_bus(i2c); 328 - spacemit_i2c_reset(i2c); 329 - return -ETIMEDOUT; 330 - } 331 - 332 - if (i2c->status & SPACEMIT_SR_ERR) 333 - return spacemit_i2c_handle_err(i2c); 334 - } 335 - 336 - return 0; 337 - } 338 - 339 308 static bool spacemit_i2c_is_last_msg(struct spacemit_i2c_dev *i2c) 340 309 { 341 310 if (i2c->msg_idx != i2c->msg_num - 1) ··· 386 417 387 418 i2c->state = SPACEMIT_STATE_IDLE; 388 419 complete(&i2c->complete); 420 + } 421 + 422 + static int spacemit_i2c_xfer_msg(struct spacemit_i2c_dev *i2c) 423 + { 424 + unsigned long time_left; 425 + struct i2c_msg *msg; 426 + 427 + for (i2c->msg_idx = 0; i2c->msg_idx < i2c->msg_num; i2c->msg_idx++) { 428 + msg = &i2c->msgs[i2c->msg_idx]; 429 + i2c->msg_buf = msg->buf; 430 + i2c->unprocessed = msg->len; 431 + i2c->status = 0; 432 + 433 + reinit_completion(&i2c->complete); 434 + 435 + spacemit_i2c_start(i2c); 436 + 437 + time_left = wait_for_completion_timeout(&i2c->complete, 438 + i2c->adapt.timeout); 439 + if (!time_left) { 440 + dev_err(i2c->dev, "msg completion timeout\n"); 441 + spacemit_i2c_conditionally_reset_bus(i2c); 442 + spacemit_i2c_reset(i2c); 443 + return -ETIMEDOUT; 444 + } 445 + 446 + if (i2c->status & SPACEMIT_SR_ERR) 447 + return spacemit_i2c_handle_err(i2c); 448 + } 449 + 450 + return 0; 389 451 } 390 452 391 453 static irqreturn_t spacemit_i2c_irq_handler(int irq, void *devid)