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

Input: imx6ul_tsc - unify open/close and PM paths

Open/close and resume/suspend paths are very similar, let's factor out
common parts.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+22 -30
+22 -30
drivers/input/touchscreen/imx6ul_tsc.c
··· 315 315 return IRQ_HANDLED; 316 316 } 317 317 318 - static int imx6ul_tsc_open(struct input_dev *input_dev) 318 + static int imx6ul_tsc_start(struct imx6ul_tsc *tsc) 319 319 { 320 - struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); 321 320 int err; 322 321 323 322 err = clk_prepare_enable(tsc->adc_clk); ··· 348 349 return err; 349 350 } 350 351 351 - static void imx6ul_tsc_close(struct input_dev *input_dev) 352 + static void imx6ul_tsc_stop(struct imx6ul_tsc *tsc) 352 353 { 353 - struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); 354 - 355 354 imx6ul_tsc_disable(tsc); 356 355 357 356 clk_disable_unprepare(tsc->tsc_clk); 358 357 clk_disable_unprepare(tsc->adc_clk); 358 + } 359 + 360 + 361 + static int imx6ul_tsc_open(struct input_dev *input_dev) 362 + { 363 + struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); 364 + 365 + return imx6ul_tsc_start(tsc); 366 + } 367 + 368 + static void imx6ul_tsc_close(struct input_dev *input_dev) 369 + { 370 + struct imx6ul_tsc *tsc = input_get_drvdata(input_dev); 371 + 372 + imx6ul_tsc_stop(tsc); 359 373 } 360 374 361 375 static int imx6ul_tsc_probe(struct platform_device *pdev) ··· 521 509 522 510 mutex_lock(&input_dev->mutex); 523 511 524 - if (input_dev->users) { 525 - imx6ul_tsc_disable(tsc); 526 - 527 - clk_disable_unprepare(tsc->tsc_clk); 528 - clk_disable_unprepare(tsc->adc_clk); 529 - } 512 + if (input_dev->users) 513 + imx6ul_tsc_stop(tsc); 530 514 531 515 mutex_unlock(&input_dev->mutex); 532 516 ··· 538 530 539 531 mutex_lock(&input_dev->mutex); 540 532 541 - if (!input_dev->users) 542 - goto out; 533 + if (input_dev->users) 534 + retval = imx6ul_tsc_start(tsc); 543 535 544 - retval = clk_prepare_enable(tsc->adc_clk); 545 - if (retval) 546 - goto out; 547 - 548 - retval = clk_prepare_enable(tsc->tsc_clk); 549 - if (retval) { 550 - clk_disable_unprepare(tsc->adc_clk); 551 - goto out; 552 - } 553 - 554 - retval = imx6ul_tsc_init(tsc); 555 - if (retval) { 556 - clk_disable_unprepare(tsc->tsc_clk); 557 - clk_disable_unprepare(tsc->adc_clk); 558 - goto out; 559 - } 560 - out: 561 536 mutex_unlock(&input_dev->mutex); 537 + 562 538 return retval; 563 539 } 564 540