Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1466006pxb; Fri, 13 Nov 2020 13:30:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPugT9mh/IdYw2AxQDyru2KNLThj01DAJAJi0qHGvhFVkrZJM2az9QFCpwUcORDe4FptHM X-Received: by 2002:a17:906:a108:: with SMTP id t8mr3918678ejy.435.1605303016257; Fri, 13 Nov 2020 13:30:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605303016; cv=none; d=google.com; s=arc-20160816; b=iVezMGnRc+T0ItZaBijSTGyY3uOhd86xbouUdQofogNtvN34l4nwlvZg3Jm/DpjFk7 MA3ghD8m1qnzyt2xCa5qVy1CK5LAs69funYq6Kc3tz3BnuZ14RfWC2Uqm/1anC2HrDN1 Cf+2qwgy9Vf/zON0il7312SHAuMaZOtTYfjf7PV627MxQvbDjZV8q+HzjONAWxmJwlZw 8npsuZlZ2YfaWhh9kYAVnmq6O6ObbCHPmt9E1f2PLs0BFFuDOlVy8IXggBQlcBies/Bk hjO7K7nUf/FsaYSe/tsSvA6Uyb6UvB8e/M8PfclVUF8b65HAHseJ6ca/bg8wMyj1x37t MXvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WtOlfh2iN8I6ixuIiavCx+KW4I1eJq4Nkock3YvzBRE=; b=00enM3BkU3L3pyDsRELpu4HQqIJLA9zuEGGfzja6MoWZxa1WQ/WKdV3sWx+xbLC/38 bsAksppL7rdVLMn7TZTq2wQiBMQQbqFl5XP77e0fpmIjGnbRLrpHV667Ceq7X6UKhCSL /20Wvo8PoWFyZNkDVJhNmeysHCPCedK8s9E4mu/xFYqVzSswATtMXNjo2P0lPzosU/8S fTL5bDCy+/pGF6WnWanUdGitAhrbika5NP3yvKBOzwGL3L6+Ey8vLFUlL5m90J9rFtao 0RYWFt3nD5/8wny1lAvrpcQXkQsDwwkfJW4LVGHTpES6FSBfH+O/VUEeIeHcFIQYyhzB os5A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oi23si6677452ejb.676.2020.11.13.13.29.53; Fri, 13 Nov 2020 13:30:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726441AbgKMV1i (ORCPT + 99 others); Fri, 13 Nov 2020 16:27:38 -0500 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:35181 "EHLO relay6-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbgKMV1K (ORCPT ); Fri, 13 Nov 2020 16:27:10 -0500 X-Originating-IP: 86.194.74.19 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id F1947C0005; Fri, 13 Nov 2020 21:27:04 +0000 (UTC) From: Alexandre Belloni To: Jonathan Cameron Cc: Lars-Peter Clausen , Peter Meerwald-Stadler , Nicolas Ferre , Ludovic Desroches , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Belloni Subject: [PATCH 7/9] iio: adc: at91_adc: use devm_input_allocate_device Date: Fri, 13 Nov 2020 22:26:48 +0100 Message-Id: <20201113212650.507680-8-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113212650.507680-1-alexandre.belloni@bootlin.com> References: <20201113212650.507680-1-alexandre.belloni@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use devm_input_allocate_device to allocate the input device to simplify the error and remove paths. Signed-off-by: Alexandre Belloni --- drivers/iio/adc/at91_adc.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 76aeebce6f4d..d09ceb315c5a 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -937,9 +937,8 @@ static int at91_ts_register(struct iio_dev *idev, { struct at91_adc_state *st = iio_priv(idev); struct input_dev *input; - int ret; - input = input_allocate_device(); + input = devm_input_allocate_device(&pdev->dev); if (!input) { dev_err(&idev->dev, "Failed to allocate TS device!\n"); return -ENOMEM; @@ -964,8 +963,7 @@ static int at91_ts_register(struct iio_dev *idev, if (st->touchscreen_type != ATMEL_ADC_TOUCHSCREEN_4WIRE) { dev_err(&pdev->dev, "This touchscreen controller only support 4 wires\n"); - ret = -EINVAL; - goto err; + return -EINVAL; } input_set_abs_params(input, ABS_X, 0, (1 << MAX_RLPOS_BITS) - 1, @@ -977,20 +975,7 @@ static int at91_ts_register(struct iio_dev *idev, st->ts_input = input; input_set_drvdata(input, st); - ret = input_register_device(input); - if (ret) - goto err; - - return ret; - -err: - input_free_device(st->ts_input); - return ret; -} - -static void at91_ts_unregister(struct at91_adc_state *st) -{ - input_unregister_device(st->ts_input); + return input_register_device(input); } static int at91_adc_probe(struct platform_device *pdev) @@ -1203,8 +1188,6 @@ static int at91_adc_probe(struct platform_device *pdev) if (!st->touchscreen_type) { at91_adc_trigger_remove(idev); at91_adc_buffer_remove(idev); - } else { - at91_ts_unregister(st); } error_disable_adc_clk: clk_disable_unprepare(st->adc_clk); @@ -1224,8 +1207,6 @@ static int at91_adc_remove(struct platform_device *pdev) if (!st->touchscreen_type) { at91_adc_trigger_remove(idev); at91_adc_buffer_remove(idev); - } else { - at91_ts_unregister(st); } clk_disable_unprepare(st->adc_clk); clk_disable_unprepare(st->clk); -- 2.28.0