From patchwork Sat Apr 23 20:47:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 8918941 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C04949F39A for ; Sat, 23 Apr 2016 20:47:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3A6A201F2 for ; Sat, 23 Apr 2016 20:47:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB31F201EC for ; Sat, 23 Apr 2016 20:47:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752134AbcDWUr2 (ORCPT ); Sat, 23 Apr 2016 16:47:28 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:38066 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752038AbcDWUr2 (ORCPT ); Sat, 23 Apr 2016 16:47:28 -0400 Received: by mail-wm0-f49.google.com with SMTP id u206so72832606wme.1 for ; Sat, 23 Apr 2016 13:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=+jVvoA0VRchSsSX2p9rveHm9DHDF3R5drYsnDgw4Ru4=; b=mnjEjQtkQGy0NdP8ApE+IW9CHfcQNUvOvImm+yfHYbIiXPAXCWJv5l7CjzqDWDkqJm axjrkN+tNVSIJuu6ttThOKiXHxIL/zma0ovTNmoWPUHnaieXsTVAsPsX/w/e/N2VxuYd JibWDdLLo7g8AjoqD6Dmtyl0FQ21s+5J1GetMD6wrN6hiO3Fmd7tOdEsPIjPZCSZeCt0 nJXcfEKtoEhfMSdI7ta573wIlIjnSccHbg+cf9A2fvno+9zTDwBLzjb6mCJpxNFoQ7Zg 2+jsqZXh6VM+nX7DyEkaYcbMp7/x3bEtGmbwLcCYMj6qeDfGPCe7VHNEy1xCs2UjHuYB Te+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=+jVvoA0VRchSsSX2p9rveHm9DHDF3R5drYsnDgw4Ru4=; b=Xy5WLIifW7ltYlsitrvRXZg/FJdJihLUnsXJlHyXv92lXhWxu7BGGUGQ3M8w2KvsE0 cr0MTEJ304z25b0aHy3cSbCnzC4EWJXPOl9A8MKOmI0RDsmwJU/gQh5dwtPDz3qaKqFG BOQ6QqckXn4SJJrcCmp6LUsngEGgWv504DwuXqfwPtm01ej88J/QrHvAIc8gSdHrPUmg b2OdoMSRszoUSjZjj2ERF0czZo7mABAHcyIK18xgln7lHay8FebDkQGl51xNJ2DJH9JS 88LNo9gLaCaYLHA5drAtS+JyrNHPBPXC2EDo7T4lysdQO24l5yaae68EbI24A8DprS2s 6Y2Q== X-Gm-Message-State: AOPr4FXqMLSOEqNdtnZg/BiOKduY+hyvJZQ37g0A9aMLRGBqNR+Wu5Rq/DLELQWhStHxZQ== X-Received: by 10.28.150.142 with SMTP id y136mr4082989wmd.28.1461444446433; Sat, 23 Apr 2016 13:47:26 -0700 (PDT) Received: from ?IPv6:2003:62:5f01:4400:f82f:457e:2650:1248? (p200300625F014400F82F457E26501248.dip0.t-ipconnect.de. [2003:62:5f01:4400:f82f:457e:2650:1248]) by smtp.googlemail.com with ESMTPSA id gk4sm14748587wjd.7.2016.04.23.13.47.25 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 23 Apr 2016 13:47:25 -0700 (PDT) To: Mark Brown Cc: "linux-spi@vger.kernel.org" From: Heiner Kallweit Subject: [PATCH] spi: core: add hook flash_read_supported to spi_master Message-ID: <571BDF4C.1000102@gmail.com> Date: Sat, 23 Apr 2016 22:47:08 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If hook spi_flash_read is implemented the fast flash read feature is enabled for all devices attached to the respective master. In most cases there is just one flash chip, however there are also devices with more than one flash chip, namely some WiFi routers. Then the fast flash read feature can be used for the first chip only. OpenWRT implemented an own handling of this case, using controller_data element of spi_device to hold the information whether fast flash read can be used for a device. This patch adds hook flash_read_supported to spi_master which is used to extend spi_flash_read_supported() by checking whether the fast flash read feature can be used for a specific spi_device. If the hook is not implemented the default behavior is to allow fast flash read for all devices (if spi_flash_read is implemented). Signed-off-by: Heiner Kallweit --- include/linux/spi/spi.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 857a9a1..1f03483 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -372,6 +372,7 @@ static inline void spi_unregister_driver(struct spi_driver *sdrv) * @unprepare_message: undo any work done by prepare_message(). * @spi_flash_read: to support spi-controller hardwares that provide * accelerated interface to read from flash devices. + * @flash_read_supported: spi device supports flash read * @cs_gpios: Array of GPIOs to use as chip select lines; one per CS * number. Any individual value may be -ENOENT for CS lines that * are not GPIOs (driven by the SPI controller itself). @@ -529,6 +530,7 @@ struct spi_master { struct spi_message *message); int (*spi_flash_read)(struct spi_device *spi, struct spi_flash_read_message *msg); + bool (*flash_read_supported)(struct spi_device *spi); /* * These hooks are for drivers that use a generic implementation @@ -1158,7 +1160,9 @@ struct spi_flash_read_message { /* SPI core interface for flash read support */ static inline bool spi_flash_read_supported(struct spi_device *spi) { - return spi->master->spi_flash_read ? true : false; + return spi->master->spi_flash_read && + (!spi->master->flash_read_supported || + spi->master->flash_read_supported(spi)); } int spi_flash_read(struct spi_device *spi,