Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp1291251ybg; Fri, 18 Oct 2019 15:19:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOttevvtYwf49HbZoFUi8tTGakA7S/yGJ9F2VC7CZc+P/dy0Q6UemvDyCUByKf4Y6fnJmY X-Received: by 2002:a05:6402:2046:: with SMTP id bc6mr12461239edb.147.1571437145969; Fri, 18 Oct 2019 15:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571437145; cv=none; d=google.com; s=arc-20160816; b=yi6Nf7zAtLXC+vb06ARqxIRrySiiL9UO+iKemy49UA3bpEbaIMJVtgRXgkwH2gNiLe 1s6i2S2BtYLrfDB3j7X54/rdOTdF+z3uxTC3zusCgVktKz1ud145YdQFFO9IVusSam0S Nj7Z6Qzj3VJFgqe0QITlENlIT51BgsQhYM+3piWDKBchquEKfcweStFDw+bFbI+Rfnmy oQfIgSHoYHM5mXzZEH3o7aEh8+xmzq2NrqhTn/gNwggA8dDhpmJx1jDUWCNCFmGeUab0 ADWJ1NcPYo/YCJb253A31nfkVNuO0lSADfWCx87kQF7BSNLKaf0/lQ0XuAZbjizYdlQV aZqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HlyTv1vxc6ePybQkoO4f5oM/4dcEruouJB05duaVKOg=; b=YnsirZFhi5DENqtuYgGj4IU78W9vv2Bo2CBbjo+L1Jed71HcRv6DHEnZkIVFVyaMBg Xckv+6FfdjWavZfObGaheQGXx6Hl6q4CdFC4kWoUvmF9mslL5dp4BENlfxpDmcjkvnA/ lMnGAIPFHOdBUYMP0xqLkLM2da5vQkKnuwta/SjP/s4bt3rylIZmzBB2I+kylLou+KEV Q5xVDrKKAelJfjnUeJ3MhnJOSbJnhnYvq3CTnRqrKfB+lZ51rKVK9Y3me24sjHs7a7Xg EgYXbDe1iTQ2mL1kjZBaCOCJhtUQGgo4zYlvHXN9VooGeEI4Sbzgo1nicXt7UBX9zGRB TyzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Etg86CwG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gu8si4357878ejb.107.2019.10.18.15.18.43; Fri, 18 Oct 2019 15:19:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Etg86CwG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503144AbfJQUm4 (ORCPT + 99 others); Thu, 17 Oct 2019 16:42:56 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35670 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502467AbfJQUmk (ORCPT ); Thu, 17 Oct 2019 16:42:40 -0400 Received: by mail-pg1-f194.google.com with SMTP id p30so2035378pgl.2; Thu, 17 Oct 2019 13:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HlyTv1vxc6ePybQkoO4f5oM/4dcEruouJB05duaVKOg=; b=Etg86CwGZ+v3CIcN3+OB9F2ezo3lxulhWGvKvFJ/Khi2bemD+HihqF4RzcPR/QO/XU cEpINIkKoz4HldLf/AQwdqTskzwveI1ITM3xLiSULviKiFauPsIKhg3xgatCy00zN+41 zwxYlUvUoJauPL6GJ2GyIgJ5OSJ7TMEVIdPIYBWLW+upLso81zbsRuX0//zV4lT0piAU FIP6XqLXzcXXX53tSCPMDnjByp0Ys0yaufH3JDRpCGNoMeRYLahuD9sYCDD/yugvJk1C Fm7GxgKzRfDPSbvUMxkVg6MVTIW8UpT87L6I8X7dn4f6mnbGSFicZ29tmmXpAfZ9+OLT WPNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HlyTv1vxc6ePybQkoO4f5oM/4dcEruouJB05duaVKOg=; b=mh/JoiBY02hrgyunRDWhArL1q1DyBGU0WgqL8XmYEpTcreK2jqJZtcRo54IH8TvarA FthzLXmGpKP3vyPkppofmW/tQIQJCxY6eTef7KyEJouDV0IH3W/vDmgUezw3eryIgp+i WqLcr+qOYSqE0wLLNEQVzeVgbFDivrAxAt0t/CDVsYB58GF34UqXpP3W130zoxRbAIwQ M8cte37ofZ6wSGZ/TM8d69UFY6kIvlCZtEU9QQbEBcapCQNcOSXjkWSZ/lK4Og5YKI8+ MKzWJJchE5tYC6Pj6UYZbuRUvluF7TcnfQ82ITlo7wnYJv/egHSxLssqbQiV5hcs/DVl XSzg== X-Gm-Message-State: APjAAAXJRyeunsycgSC9Nw8PIbHUZqpgyz/RwR/23s/jMzt8bLYr35b3 BXVefyXEMp1AoChpkiCR78rsLJfA X-Received: by 2002:a17:90a:858a:: with SMTP id m10mr6937186pjn.128.1571344958930; Thu, 17 Oct 2019 13:42:38 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id b3sm4626365pfd.125.2019.10.17.13.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 13:42:38 -0700 (PDT) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Allison Randal , Jilayne Lovejoy , Steve Winslow , linux-kernel@vger.kernel.org Subject: [PATCH 13/22] Input: sgi_btns - switch to using managed resources Date: Thu, 17 Oct 2019 13:42:07 -0700 Message-Id: <20191017204217.106453-14-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.23.0.866.gb869b98d4c-goog In-Reply-To: <20191017204217.106453-1-dmitry.torokhov@gmail.com> References: <20191017204217.106453-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Switching to devm API allows to clean up error handling paths and drop the remove() method. Signed-off-by: Dmitry Torokhov --- drivers/input/misc/sgi_btns.c | 37 ++++++++--------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/drivers/input/misc/sgi_btns.c b/drivers/input/misc/sgi_btns.c index 0fee6ddf3602..829277b4271f 100644 --- a/drivers/input/misc/sgi_btns.c +++ b/drivers/input/misc/sgi_btns.c @@ -45,7 +45,6 @@ static const unsigned short sgi_map[] = { }; struct buttons_dev { - struct input_polled_dev *poll_dev; unsigned short keymap[ARRAY_SIZE(sgi_map)]; int count[ARRAY_SIZE(sgi_map)]; }; @@ -84,12 +83,13 @@ static int sgi_buttons_probe(struct platform_device *pdev) struct input_dev *input; int error, i; - bdev = kzalloc(sizeof(struct buttons_dev), GFP_KERNEL); - poll_dev = input_allocate_polled_device(); - if (!bdev || !poll_dev) { - error = -ENOMEM; - goto err_free_mem; - } + bdev = devm_kzalloc(&pdev->dev, sizeof(*bdev), GFP_KERNEL); + if (!bdev) + return -ENOMEM; + + poll_dev = devm_input_allocate_polled_device(&pdev->dev); + if (!poll_dev) + return -ENOMEM; memcpy(bdev->keymap, sgi_map, sizeof(bdev->keymap)); @@ -101,7 +101,6 @@ static int sgi_buttons_probe(struct platform_device *pdev) input->name = "SGI buttons"; input->phys = "sgi/input0"; input->id.bustype = BUS_HOST; - input->dev.parent = &pdev->dev; input->keycode = bdev->keymap; input->keycodemax = ARRAY_SIZE(bdev->keymap); @@ -113,35 +112,15 @@ static int sgi_buttons_probe(struct platform_device *pdev) __set_bit(bdev->keymap[i], input->keybit); __clear_bit(KEY_RESERVED, input->keybit); - bdev->poll_dev = poll_dev; - platform_set_drvdata(pdev, bdev); - error = input_register_polled_device(poll_dev); if (error) - goto err_free_mem; - - return 0; - - err_free_mem: - input_free_polled_device(poll_dev); - kfree(bdev); - return error; -} - -static int sgi_buttons_remove(struct platform_device *pdev) -{ - struct buttons_dev *bdev = platform_get_drvdata(pdev); - - input_unregister_polled_device(bdev->poll_dev); - input_free_polled_device(bdev->poll_dev); - kfree(bdev); + return error; return 0; } static struct platform_driver sgi_buttons_driver = { .probe = sgi_buttons_probe, - .remove = sgi_buttons_remove, .driver = { .name = "sgibtns", }, -- 2.23.0.866.gb869b98d4c-goog