From patchwork Wed Sep 20 18:31:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9962015 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 27C616056D for ; Wed, 20 Sep 2017 18:34:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12FBE286D2 for ; Wed, 20 Sep 2017 18:34:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05E6B2920E; Wed, 20 Sep 2017 18:34:46 +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=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED 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 0E12729202 for ; Wed, 20 Sep 2017 18:34:44 +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=zFCa9wzb6vlbo1NqeXVK4p+sgC/0WfdEaJbM3fggYns=; b=OT+ 0v0dhDen7taVbGWMgXTXSlP2FNdsNi6hbVG70RgBAbffE7zTPO4xAzjecYrSydA9876kPEDeyypbU piuZlX7V/xSKM8k5KyVOXlE66aafF6ms3NWAM3DPm5D/Iuev6iSA+yCr8ARJ60GZcwGQ2TTM9A44V oy9lFylOD+JCRki/kivoAeFP5rQEPTN+VKIY7wck+e92FhAfhINwt3W10SyAJPxi/N2jS0Hwe/FG1 IF4TQZaLmrRZNv+/PtTP6AJXbqz7ZrrAwkoKbScJvlpkiCVJdmz1ytbK5awO4UETKAgkGqH5FQUx9 Fx4z0xr2+ju7PC0qgdPTvLr6Ax3xQIA==; 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 1dujpJ-000518-K6; Wed, 20 Sep 2017 18:34:25 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dujpE-0004mZ-Sz for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2017 18:34:22 +0000 Received: by mail-wm0-x241.google.com with SMTP id m127so3204643wmm.0 for ; Wed, 20 Sep 2017 11:33:59 -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=qecTTriBgloUPXentQ6ny2FSXMxEDR8kPq8aIu/pU3c=; b=KSZYTHGaa2E4CZQQM9LcJ2lMACbbIbW1NQ/QRyd3MrhfcRn4+X7epQg/zAl+R+3Zl1 0EBZwbXmAvgpE9uK+/eWXgC7ARMiTOzRRYdTmiVSI05r7rPvQNbZOao68zZ91Evv09H5 sLCAfO14f+xhoXjgAP8ckug1aQKtwOZ7netDexw4zsh4QStSagO9TUAnkyQk3zSbW8Ao 9cM5l2Tt3KyX0/iJyRW9/Y9ZGvKYatJAA9Op96tpb5y0sq0FQNGgP19i/zvBbl/u+Aav l/MluidR/bNo3Jt/pKZOfPPBsiaNQclIRsdSJtYrO2IpmiHkWQQViwNIUaWXz6BGtPHk lb9Q== 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=qecTTriBgloUPXentQ6ny2FSXMxEDR8kPq8aIu/pU3c=; b=lJbhMzg8z80hHZ0PoAA5+/LjBWEZ7lzLRemqIWyT33fBDPkOEuIn8LwfkROVwgAFBj kZHkMIxaERMAYVp1DUKYzAnKwWcNEuxExyeCP6gn/jNuy4JKvhZnxotnQbXvtkEkAEFy Y2eUB4zbyTPIJLANpztSOYtpAGCXCuhU6iY61EGuU0rBbygy/mA6IJvVgh65yXbqFwPa BCIBV1FCmGiE0Q5EUTHInf+FH5vumI7Qg+kXTeE840Arxt+XQjcwl0LwEgQ6yt3fU3BV 1N81QOuNzNBVMIFm8EaGLvwHQaQZH1PF1UCrOtkMBuTsnjN87xpYjnVP839eSmq7l56D 59FQ== X-Gm-Message-State: AHPjjUjjPC2zgBk0tn2EC29Hd12MIU/dI6gM4Rhzn/axybgV3aNY280x +8KEU/l8+stI0YAhND7qlEs= X-Google-Smtp-Source: AOwi7QDOmpF43a1+ZwSPkPJpvHoQOV/CamdvkA+puN9BiA6k9wo4/4+Cf6E2gDZ9wU3pkAqs3jWv+Q== X-Received: by 10.28.125.6 with SMTP id y6mr5186318wmc.85.1505932438375; Wed, 20 Sep 2017 11:33:58 -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 l126sm2227220wmd.1.2017.09.20.11.33.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 11:33:57 -0700 (PDT) From: Corentin Labbe To: herbert@gondor.apana.org.au, davem@davemloft.net, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com Subject: [PATCH] crypto: stm32: use of_device_get_match_data Date: Wed, 20 Sep 2017 20:31:40 +0200 Message-Id: <20170920183140.17018-1-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170920_113421_166395_5D934371 X-CRM114-Status: GOOD ( 10.88 ) 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: Corentin Labbe , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.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/crypto/stm32/stm32-hash.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index b585ce54a802..1d9285c62606 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -1408,11 +1408,10 @@ MODULE_DEVICE_TABLE(of, stm32_hash_of_match); static int stm32_hash_get_of_match(struct stm32_hash_dev *hdev, struct device *dev) { - const struct of_device_id *match; int err; - match = of_match_device(stm32_hash_of_match, dev); - if (!match) { + hdev->pdata = of_device_get_match_data(dev); + if (!hdev->pdata) { dev_err(dev, "no compatible OF match\n"); return -EINVAL; } @@ -1420,8 +1419,6 @@ static int stm32_hash_get_of_match(struct stm32_hash_dev *hdev, err = of_property_read_u32(dev->of_node, "dma-maxburst", &hdev->dma_maxburst); - hdev->pdata = match->data; - return err; }