Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966477AbcLVQjy (ORCPT ); Thu, 22 Dec 2016 11:39:54 -0500 Received: from exsmtp02.microchip.com ([198.175.253.38]:49372 "EHLO email.microchip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966193AbcLVQiC (ORCPT ); Thu, 22 Dec 2016 11:38:02 -0500 From: Cyrille Pitchen To: , , CC: , , , Cyrille Pitchen Subject: [PATCH v2 05/12] crypto: atmel-sha: add atmel_sha_wait_for_data_ready() Date: Thu, 22 Dec 2016 17:37:54 +0100 Message-ID: <4acd571517ee8919b65765de30da2b8e8a73bbed.1482424395.git.cyrille.pitchen@atmel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Brightmail-Tracker: H4sIAAAAAAAAC+NgFupgVWLjYuHi8mHRzWSMiTD4+W/mFkaLwwunMFo8eN/JYjFt+jtmi3uftjFadExZxeTAGsAQxZqZl5RfkcCaMfvBY5aCudwVH54qNDAu4exi5OIQEljHKLG5t5Gli5GTg03AUOLtg6OsILaIQKDEwpZXjCBFzALTGSUerH7HDpIQFgiQ+DrpMpjNIqAq8eLELKAGDg5egXiJpRczQMISAnISN891MoPYnAK2Euvn3gMrERKwkTj4VggkzCsgKHFy5hOwtcwCEhIHX7wAKxcSUANau4IZYkygxIe1e6BsJ4lZPzezQNh2EoenX2SHsO0lLu27xAJTc+njCyYIW1ti+6t9rBC2jsS2g/1QNbYSe2ZMhKpxl3jwaDmU7Ssx62EDVE2UxO3mXewTGCVmITl1FpJTFzAyrWKUdvbw0w0O03WNcPYwMNLLTc4o0M1NzMzTS87P3cQIiSW1HYwze/wPMUpyMCmJ8m6ddD5ciC8pP6UyI7E4I76oNCe1+BCjBAePkgjvxuVAOd7igsTc4sx0mJQMB4eSBG8ESEqwKDU9tSItM6cktQgifYpRUkqcNxokKQDSl1GaB5e7xCgqJcwbtRQox1OQWpSbWQIRv8UozPGQSYglLz8vVQroRAYg0GB8xSjOwagkzLsfZBZPZl4J3AmvgK5jArpu3e7TINeVJCKkpBoYGWUff7w56fNBGTGG+3/v3etkYnxSVp+g4PVgEvMP09/P/2ZML0/8+yEzmenv1G5j1oSoqlfPdt3VCrzJlvHB/Aq33aNpjj0iC1503cyTC2ev0LrqdvDdK4mJ03Nj3U4y1c+d0SWjZ88Z4Pzz3OrlU8w97V7ICTj1XmyO3MUlN93dae1+nzNqSizFGYmGWsxFxYkA242ptxsDAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1394 Lines: 41 This patch simply defines a helper function to test the 'Data Ready' flag of the Status Register. It also gives a chance for the crypto request to be processed synchronously if this 'Data Ready' flag is already set when polling the Status Register. Indeed, running synchronously avoid the latency of the 'Data Ready' interrupt. When the 'Data Ready' flag has not been set yet, we enable the associated interrupt and resume processing the crypto request asynchronously from the 'done' task just as before. Signed-off-by: Cyrille Pitchen --- drivers/crypto/atmel-sha.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index b29a4e5bc404..be0d72cf4352 100644 --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c @@ -434,6 +434,19 @@ static void atmel_sha_write_ctrl(struct atmel_sha_dev *dd, int dma) atmel_sha_write(dd, SHA_MR, valmr); } +static inline int atmel_sha_wait_for_data_ready(struct atmel_sha_dev *dd, + atmel_sha_fn_t resume) +{ + u32 isr = atmel_sha_read(dd, SHA_ISR); + + if (unlikely(isr & SHA_INT_DATARDY)) + return resume(dd); + + dd->resume = resume; + atmel_sha_write(dd, SHA_IER, SHA_INT_DATARDY); + return -EINPROGRESS; +} + static int atmel_sha_xmit_cpu(struct atmel_sha_dev *dd, const u8 *buf, size_t length, int final) { -- 2.7.4