From patchwork Fri Oct 20 05:37:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 10018939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 05B9F60211 for ; Fri, 20 Oct 2017 05:40:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAEBA28EA8 for ; Fri, 20 Oct 2017 05:40:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDE2228EAB; Fri, 20 Oct 2017 05:40:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 76E4F28EA8 for ; Fri, 20 Oct 2017 05:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=5efGSHnsP7AmTKONmjJXmeir0j+6Xe69xm/XBLQ23jc=; b=g0M ZjKcBzTWf03hrADXsMPF3khYMgA9AtFiFgY9bPEJlrxAL3FbFOkqHTf9B6ovRLDUtu++S2UL0QCed izQ6pikJ/jzIloWODmK6jyqkiNXAUBgpLuLa8QGR6aJbRItktnbBziJix7j8bl0CPLZZBacZfQLhx bxnK1C0mlBYJqB8OK2Sr6nYk8VVC/0C7eHwsYQ4HaK5/+t/hURuCFW+ThaDRDU+2CFfPqZps+bRTM 2kRzqtychOwsvx+GABaFuUAFL/l/MsDOqO13QDQsMcYkYmojFbo/Eap0eS2+Gk1t4FBxtzExKe9/S Ivyc2Tek987TiLb2M39fYIJTHl/D3Bg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e5Q2O-0001uo-Qr; Fri, 20 Oct 2017 05:40:04 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e5Q2K-0001ZW-Ql for linux-arm-kernel@lists.infradead.org; Fri, 20 Oct 2017 05:40:02 +0000 Received: by mail-wr0-x241.google.com with SMTP id l1so10321731wrc.3 for ; Thu, 19 Oct 2017 22:39:40 -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; bh=3K0xZUY2+wnx7IrNlpXtI/BjeNpg+U61bTq5+E0vm9Q=; b=RCKMZvcqHOVu7uCFULxROJvebn53o9qdxw2XXpRWmsq6AIJqkyyo+hNlZw4ak3XyQw kw9N/yYTffD5pUmlQHlPHoZoVEJaVxJQwDKvnBIqYwm1RN9X5YF4rowDvUdFIrcx0WQe re/LUupgxFNW3UlM4qVx0IiXBpWZoGA1D87c8TtcTkt8dLvflEih497+qP3ioAFom+vG EB1jtKi7qsNxJNlNdtWNZ1KPs1OlIKoZ/lDz5B6o7rJbfaLXdnZGT/nFN/YbHmt2W3Pw nfpZE65MWiSsEUBa8Qx+VmUE4tDuJYBkgXgmDd55nhwWx0DNr5YIl3vH+GOdl6x7FiDi r1aw== 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; bh=3K0xZUY2+wnx7IrNlpXtI/BjeNpg+U61bTq5+E0vm9Q=; b=krMR65D1lOOMVj8OY5ZuflM07sdKlgErbXgWtp/jvrXr475nMyhPtIKYFAJfFy73BN r3ITr2MVy6NO1MvXQEPaXM40xL+Wn0gv0Ixw518UTOtDdL0ouepbhufdtz+odhJIwzed FyrwwfIdUYO+p0AD2/4YueU+qJZ+5u8wbYEi8zTW6/RQCNuT6yejAcXoSGjMSYcy5dJ1 Fv+7qgynqrN49msoq/oaemtYz+ZP1SuMflA35PwBlPvPM948buOGNxYcZuIuhry68AZC TU6e6fQtkbcNm6ft3sCPI1UyUsSnU8b9XHDpB5p/iLJlMOPImzGW1g76i1lSEM7vH8jX sMeQ== X-Gm-Message-State: AMCzsaX8cJe2ihFgNZnV2qRR/C2DwCB+auYDw+1hpkIOaUjnXXV8j8ls Zd0n9nN6EKq09tFjCHzPaHXbM5vk X-Google-Smtp-Source: ABhQp+Rmn6WbNL20rdw4LbGodDYC9fWNRH3DYnBESM/8RaoTuI7UaeQEVLgCL2RcApdHObm7XW0Q/g== X-Received: by 10.223.199.205 with SMTP id y13mr3622227wrg.71.1508477979048; Thu, 19 Oct 2017 22:39:39 -0700 (PDT) Received: from Red.local (LFbn-MAR-1-580-96.w90-118.abo.wanadoo.fr. [90.118.159.96]) by smtp.googlemail.com with ESMTPSA id m26sm298660wrb.81.2017.10.19.22.39.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Oct 2017 22:39:38 -0700 (PDT) From: Corentin Labbe To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, maxime.ripard@free-electrons.com, wens@csie.org, pmeerw@pmeerw.net, quentin.schulz@free-electrons.com Subject: [PATCH] iio: adc: sun4i-gpadc: use of_device_get_match_data Date: Fri, 20 Oct 2017 07:37:29 +0200 Message-Id: <20171020053729.23248-1-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171019_224001_024968_2B084E37 X-CRM114-Status: GOOD ( 10.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-iio@vger.kernel.org, Corentin Labbe , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The usage of of_device_get_match_data reduce the code size a bit. Furthermore, it prevents an improbable dereference when of_match_device() return NULL. Signed-off-by: Corentin Labbe --- drivers/iio/adc/sun4i-gpadc-iio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index c4e70f1cad79..04d7147e0110 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -501,17 +501,15 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, struct iio_dev *indio_dev) { struct sun4i_gpadc_iio *info = iio_priv(indio_dev); - const struct of_device_id *of_dev; struct resource *mem; void __iomem *base; int ret; - of_dev = of_match_device(sun4i_gpadc_of_id, &pdev->dev); - if (!of_dev) + info->data = of_device_get_match_data(&pdev->dev); + if (!info->data) return -ENODEV; info->no_irq = true; - info->data = (struct gpadc_data *)of_dev->data; indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels); indio_dev->channels = sun8i_a33_gpadc_channels;