From patchwork Wed Jul 30 12:09:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pramod Gurav X-Patchwork-Id: 4647531 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E98C5C0338 for ; Wed, 30 Jul 2014 12:16:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BB2720121 for ; Wed, 30 Jul 2014 12:16:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D785200E6 for ; Wed, 30 Jul 2014 12:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753228AbaG3MQi (ORCPT ); Wed, 30 Jul 2014 08:16:38 -0400 Received: from smtp88.ord1c.emailsrvr.com ([108.166.43.88]:43165 "EHLO smtp88.ord1c.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282AbaG3MQh (ORCPT ); Wed, 30 Jul 2014 08:16:37 -0400 X-Greylist: delayed 632 seconds by postgrey-1.27 at vger.kernel.org; Wed, 30 Jul 2014 08:16:36 EDT Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp4.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 537FD180A02; Wed, 30 Jul 2014 08:06:03 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp4.relay.ord1c.emailsrvr.com (Authenticated sender: pramod.gurav-AT-smartplayin.com) with ESMTPSA id 3B5081809B0; Wed, 30 Jul 2014 08:06:00 -0400 (EDT) X-Sender-Id: pramod.gurav@smartplayin.com Received: from SPINITLTDL00278.smartplayin.local ([UNAVAILABLE]. [220.227.185.53]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA) by 0.0.0.0:465 (trex/5.2.10); Wed, 30 Jul 2014 12:06:03 GMT From: Pramod Gurav To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pramod Gurav , Dmitry Torokhov , Paul Gortmaker Subject: [PATCH] Input: jornada720_ts: Switch to using Managed resources Date: Wed, 30 Jul 2014 17:39:43 +0530 Message-Id: <1406722183-22678-1-git-send-email-pramod.gurav@smartplayin.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This switches the driver to using managed resources to simplify error handling and to do away with remove function. Also fixes some indentations by replacing spaces with tabs. CC: Dmitry Torokhov CC: Paul Gortmaker Signed-off-by: Pramod Gurav --- drivers/input/touchscreen/jornada720_ts.c | 62 ++++++++++------------------- 1 file changed, 20 insertions(+), 42 deletions(-) diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c index 7324c5c..0c23bba 100644 --- a/drivers/input/touchscreen/jornada720_ts.c +++ b/drivers/input/touchscreen/jornada720_ts.c @@ -37,21 +37,21 @@ struct jornada_ts { static void jornada720_ts_collect_data(struct jornada_ts *jornada_ts) { - /* 3 low word X samples */ - jornada_ts->x_data[0] = jornada_ssp_byte(TXDUMMY); - jornada_ts->x_data[1] = jornada_ssp_byte(TXDUMMY); - jornada_ts->x_data[2] = jornada_ssp_byte(TXDUMMY); + /* 3 low word X samples */ + jornada_ts->x_data[0] = jornada_ssp_byte(TXDUMMY); + jornada_ts->x_data[1] = jornada_ssp_byte(TXDUMMY); + jornada_ts->x_data[2] = jornada_ssp_byte(TXDUMMY); - /* 3 low word Y samples */ - jornada_ts->y_data[0] = jornada_ssp_byte(TXDUMMY); - jornada_ts->y_data[1] = jornada_ssp_byte(TXDUMMY); - jornada_ts->y_data[2] = jornada_ssp_byte(TXDUMMY); + /* 3 low word Y samples */ + jornada_ts->y_data[0] = jornada_ssp_byte(TXDUMMY); + jornada_ts->y_data[1] = jornada_ssp_byte(TXDUMMY); + jornada_ts->y_data[2] = jornada_ssp_byte(TXDUMMY); - /* combined x samples bits */ - jornada_ts->x_data[3] = jornada_ssp_byte(TXDUMMY); + /* combined x samples bits */ + jornada_ts->x_data[3] = jornada_ssp_byte(TXDUMMY); - /* combined y samples bits */ - jornada_ts->y_data[3] = jornada_ssp_byte(TXDUMMY); + /* combined y samples bits */ + jornada_ts->y_data[3] = jornada_ssp_byte(TXDUMMY); } static int jornada720_ts_average(int coords[4]) @@ -104,13 +104,10 @@ static int jornada720_ts_probe(struct platform_device *pdev) struct input_dev *input_dev; int error; - jornada_ts = kzalloc(sizeof(struct jornada_ts), GFP_KERNEL); - input_dev = input_allocate_device(); - - if (!jornada_ts || !input_dev) { - error = -ENOMEM; - goto fail1; - } + jornada_ts = devm_kzalloc(&pdev->dev, sizeof(*jornada_ts), GFP_KERNEL); + input_dev = devm_input_allocate_device(&pdev->dev); + if (!jornada_ts || !input_dev) + return -ENOMEM; platform_set_drvdata(pdev, jornada_ts); @@ -126,36 +123,18 @@ static int jornada720_ts_probe(struct platform_device *pdev) input_set_abs_params(input_dev, ABS_X, 270, 3900, 0, 0); input_set_abs_params(input_dev, ABS_Y, 180, 3700, 0, 0); - error = request_irq(IRQ_GPIO9, + error = devm_request_irq(&pdev->dev, IRQ_GPIO9, jornada720_ts_interrupt, IRQF_TRIGGER_RISING, "HP7XX Touchscreen driver", pdev); if (error) { - printk(KERN_INFO "HP7XX TS : Unable to acquire irq!\n"); - goto fail1; + dev_err(&pdev->dev, "HP7XX TS : Unable to acquire irq!\n"); + return error; } error = input_register_device(jornada_ts->dev); if (error) - goto fail2; - - return 0; - - fail2: - free_irq(IRQ_GPIO9, pdev); - fail1: - input_free_device(input_dev); - kfree(jornada_ts); - return error; -} - -static int jornada720_ts_remove(struct platform_device *pdev) -{ - struct jornada_ts *jornada_ts = platform_get_drvdata(pdev); - - free_irq(IRQ_GPIO9, pdev); - input_unregister_device(jornada_ts->dev); - kfree(jornada_ts); + return error; return 0; } @@ -165,7 +144,6 @@ MODULE_ALIAS("platform:jornada_ts"); static struct platform_driver jornada720_ts_driver = { .probe = jornada720_ts_probe, - .remove = jornada720_ts_remove, .driver = { .name = "jornada_ts", .owner = THIS_MODULE,