From patchwork Tue Aug 29 14:13:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?H=C3=A4nel-Baas=2C_Alexander?= X-Patchwork-Id: 9927471 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 165C26022E for ; Tue, 29 Aug 2017 14:13:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0693228947 for ; Tue, 29 Aug 2017 14:13:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF6CA2894E; Tue, 29 Aug 2017 14:13:28 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 4AAE728947 for ; Tue, 29 Aug 2017 14:13:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752318AbdH2ON1 convert rfc822-to-8bit (ORCPT ); Tue, 29 Aug 2017 10:13:27 -0400 Received: from mail.sieb-meyer.de ([213.252.170.194]:23716 "EHLO mail.sieb-meyer.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751947AbdH2ON1 (ORCPT ); Tue, 29 Aug 2017 10:13:27 -0400 Received: from SMEXCHANGE01.siebmeyer.org ([::1]) by SMExchange01.siebmeyer.org ([::1]) with mapi id 14.03.0351.000; Tue, 29 Aug 2017 16:13:23 +0200 From: =?iso-8859-1?Q?H=E4nel-Baas=2C_Alexander?= To: "linux-spi@vger.kernel.org" Subject: SPI_IOC_WR_MAX_SPEED_HZ was overwitten? Thread-Topic: SPI_IOC_WR_MAX_SPEED_HZ was overwitten? Thread-Index: AdMgjWh1JiPrEsXdSH60fOpC7UI4YA== Date: Tue, 29 Aug 2017 14:13:22 +0000 Message-ID: <9BA84827B30CBE4996725F98F7DC91236563EEE4@SMExchange01.siebmeyer.org> Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.16.11.207] x-kse-antivirus-interceptor-info: scan successful x-kse-antivirus-info: Clean MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi > Is it possible that the ioctl SPI_IOC_WR_MODE call can > overwrite the previous ioctl SPI_IOC_WR_MAX_SPEED_HZ speed setting? Yes it is. Please take a look in spidev.c Line 488. In the spidev_ioctl() function at the SPI_IOC_WR_MAX_SPEED_HZ case the spi->max_speed_hz value was always overwritten with the old "save" value regardless if the spi_setup call was successful or not. --Snip-- else dev_dbg(&spi->dev, "%d Hz (max)\n", tmp); spi->max_speed_hz = save; } break; --snip-- Every following ioctl call will restore the wrong speed value. Here is my patch to correct this: Can anybody review this please? With this patch my program works fine with the spidev and the tool flashrom also. Best regards, Alexander --- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c @@ -480,11 +480,10 @@ spi->max_speed_hz = tmp; retval = spi_setup(spi); - if (retval >= 0) - spidev->speed_hz = tmp; + if (retval < 0) + spidev->speed_hz = save; else dev_dbg(&spi->dev, "%d Hz (max)\n", tmp); - spi->max_speed_hz = save; } break;