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: 10018935 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 65F3660211 for ; Fri, 20 Oct 2017 05:39:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58AEA28EA8 for ; Fri, 20 Oct 2017 05:39:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D87A28EAB; Fri, 20 Oct 2017 05:39:42 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E395B28EA8 for ; Fri, 20 Oct 2017 05:39:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751010AbdJTFjl (ORCPT ); Fri, 20 Oct 2017 01:39:41 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:54691 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750927AbdJTFjk (ORCPT ); Fri, 20 Oct 2017 01:39:40 -0400 Received: by mail-wr0-f194.google.com with SMTP id o44so10301064wrf.11; Thu, 19 Oct 2017 22:39: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; 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=b0Jx4sRRQ/JcB+Mgnd8mSpgct33NsmZj9lCD+y57OokKD2LDPaSuIjsytBi/2+L5Yu 0ri6g9ex4/jgsMYfeDZIQuEWsqV+8CAwui3I/hSkuGSUGjidpoUq0XY/K3hX7DldcGjT 4X/VnGO0x6SE4Z7XvVmhpz/HSzSaXGzpXMum1wVB0IxEji9+MnPGjXJYCPXH3oETuN2J Z2O/QBCb8gB2JX3WI9gSbb8v3jjKGZVPW1ezxHXVMnXEKc0pVYn6pbrKZp3nkDY+66id JJNyrPhniSKmllOp6J73Re8/++2Q6UP88n7hDRXmTcPztlV5Kpw8z1rFcoXOYJxJHkPK 8N2A== X-Gm-Message-State: AMCzsaVN1vforZUnyaOxoh4fRtZd+OPjuuRQqYRKLtARcvoVRVOMBtuQ sgJFPKqWgTa0PppsH9bjmZs= 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 Cc: linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Corentin Labbe 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 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.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;