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: 9962019 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 3AA7960208 for ; Wed, 20 Sep 2017 18:34:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30195286D2 for ; Wed, 20 Sep 2017 18:34:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 24F7A28EC0; Wed, 20 Sep 2017 18:34:47 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 1901429203 for ; Wed, 20 Sep 2017 18:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751609AbdITSeB (ORCPT ); Wed, 20 Sep 2017 14:34:01 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37062 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751596AbdITSd7 (ORCPT ); Wed, 20 Sep 2017 14:33:59 -0400 Received: by mail-wm0-f65.google.com with SMTP id f4so3174705wmh.4; 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=ovXEE+ASctRx/jXk9yrtWPmKhm7OAvfxf2OXLQwAkADw8tHlDj6ZiHxoUOtEEZ6sB0 16Nbk0a+jpQoJqorAgEL3mQyr7LrNXXEZgs4tBIJJ1yC2T480mnRy+tk+Pe/ZzJ+nTBB d+6vdRCXdl81Kf/5fH7vg1I3aPE/XfEIjFoprC2t6ZM9U4qgl+DfaFh6yY9UlVxFdYBP oCb9RYhxwJtAnl81YYpyyU8AUAWz97jI8HCUw2eTM/kBULdpcKcIH/hL59zvFQkfTUT4 rmKtAJK5NPA4zPSLGXv+kdA8MkzWfe6iMDL8go/qTKlqynVu6e2iguhllAKD2HqIppXj 6eBQ== X-Gm-Message-State: AHPjjUivNIEr2RhgrnqsMdyDRI9rK3VyOU9MQS7WWEP6wKKRXmrPeYbv /AOMfR+ZIHh+sRzkvnvZSYE= 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 Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Corentin Labbe 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 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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/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; }