From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05982C43217 for ; Tue, 8 Nov 2022 13:49:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234567AbiKHNtY (ORCPT ); Tue, 8 Nov 2022 08:49:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234581AbiKHNtX (ORCPT ); Tue, 8 Nov 2022 08:49:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C944F3A for ; Tue, 8 Nov 2022 05:49:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9E73B6130A for ; Tue, 8 Nov 2022 13:49:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A1F3C433D6; Tue, 8 Nov 2022 13:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667915362; bh=vgUc982+5um1Sj05/bcj04wJ6GHmCVIA6MCa4/+brT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dVEca6nB5vi3NwO06r9YLoTm4Kb6dOzSRMoIXUFC8QIpd464wLL6KkAOww9If3MOL cBQNjs3+ksoZqBqI1eu+cK2WmTT4VcqD69DW5O2rZvTW0MeuPuAQuuHmjm5sAIi9aK hK6s5I/4ZA2aJWVO7FawImkxOgYsI6A4OkJwXOVg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Sergey Shtylyov , Sasha Levin Subject: [PATCH 5.4 12/74] ata: pata_legacy: fix pdc20230_set_piomode() Date: Tue, 8 Nov 2022 14:38:40 +0100 Message-Id: <20221108133334.169428708@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221108133333.659601604@linuxfoundation.org> References: <20221108133333.659601604@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sergey Shtylyov [ Upstream commit 171a93182eccd6e6835d2c86b40787f9f832efaa ] Clang gives a warning when compiling pata_legacy.c with 'make W=1' about the 'rt' local variable in pdc20230_set_piomode() being set but unused. Quite obviously, there is an outb() call missing to write back the updated variable. Moreover, checking the docs by Petr Soucek revealed that bitwise AND should have been done with a negated timing mask and the master/slave timing masks were swapped while updating... Fixes: 669a5db411d8 ("[libata] Add a bunch of PATA drivers.") Reported-by: Damien Le Moal Signed-off-by: Sergey Shtylyov Signed-off-by: Damien Le Moal Signed-off-by: Sasha Levin --- drivers/ata/pata_legacy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/ata/pata_legacy.c b/drivers/ata/pata_legacy.c index d91ba47f2fc4..4405d255e3aa 100644 --- a/drivers/ata/pata_legacy.c +++ b/drivers/ata/pata_legacy.c @@ -278,9 +278,10 @@ static void pdc20230_set_piomode(struct ata_port *ap, struct ata_device *adev) outb(inb(0x1F4) & 0x07, 0x1F4); rt = inb(0x1F3); - rt &= 0x07 << (3 * adev->devno); + rt &= ~(0x07 << (3 * !adev->devno)); if (pio) - rt |= (1 + 3 * pio) << (3 * adev->devno); + rt |= (1 + 3 * pio) << (3 * !adev->devno); + outb(rt, 0x1F3); udelay(100); outb(inb(0x1F2) | 0x01, 0x1F2); -- 2.35.1