Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4459909ybz; Tue, 28 Apr 2020 11:39:42 -0700 (PDT) X-Google-Smtp-Source: APiQypLle8KE1NGOSau9jIxqu6FT4UNZMSuF1PEfR+5/Zk5rar3N49G1SJVKmAdXvYACGuTyMlP5 X-Received: by 2002:a17:906:7c4e:: with SMTP id g14mr26472361ejp.382.1588099182602; Tue, 28 Apr 2020 11:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588099182; cv=none; d=google.com; s=arc-20160816; b=PSOowkfWeFtMMJBv2aiFaM8RiazFu/0dzJj9iLhMy0/W/aDflP3p/tElzSv0KQh1TA IUlYFpiIym2hbUl3YJPkiM2yte8z8OYhGSbWaQAjZyDoY0j0haEN7uzRi1UdpTh7s5Sy YHAlEDhMxZAHl1QqVUPGFvb/Pj0Z4ZPuRo+D5ffYBgv2N+01DaMQwvOb/bufKDq7bUQI 0Tv8cJVfgH5Ton1bzKI/U+N2cXNIdhz60Tl1pIGsjPs5uR4DjF7pkYC+xdbghjP7T8GO kwxcavi1mHC1mcI0w2Oa0v8E+rxspxlJ7wgMC2u1alWyKfOjbpGTNkbuqatXmDG405m5 OYKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=S3j1AvRegzHFxjanWulvHacmsbu+meMgCToMbEoAQh8=; b=pie8EDYouSXV7fabG6GH30/97JwfvaaxYhX/8jl9yfKzSjAoNXOCeL1KYbN/50LfER P5OvGdocxamBsxxa1LOU+/gjSTLUe+HziM/ApX0boNNy/SQYCZv4BzqoxKwPYutkOF+8 1P5X6aMhPgSoH9O7jQt7s70u6UKFPM/Gv8s+hG/5DCwvw8JIdDln14MWh6mrAM96HYJO sJLzybUa+EwHlkvElSR++mh5S/A8VZHuU/eUOAfbXyT7P9MKAQqnGTYSGMK6MxDFC9P8 DcATN64ijfiaDioK7dvnNf2Gqs5Onm199BOAppTBEk6h/NUWYG+GgsQBH2aJrM9xcVY/ M/RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uhs+QBSL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a22si2332026edn.385.2020.04.28.11.39.19; Tue, 28 Apr 2020 11:39:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uhs+QBSL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729786AbgD1SgI (ORCPT + 99 others); Tue, 28 Apr 2020 14:36:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:53420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730331AbgD1SgC (ORCPT ); Tue, 28 Apr 2020 14:36:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 583082085B; Tue, 28 Apr 2020 18:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588098961; bh=Jq+43dOowewCe+eyDo+Q0xe3EHHPuoR53eIrtwTUFs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uhs+QBSLD2nooDmG1uwf+U8t5hMsUmr0B+jy1ExHzdeRX+StRXz+bvDbWrRWwCGWc 2DwudwEdL1Mgh6cmI293H8IOPZqCiQyOzPmq2bzX3gSu9EaPE8R2vS9LDNuN2VtQk9 4c2QoE0vT/xfPXBCW63dQGV/712shKdFxgNFKrao= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ian Abbott Subject: [PATCH 5.6 134/167] staging: comedi: dt2815: fix writing hi byte of analog output Date: Tue, 28 Apr 2020 20:25:10 +0200 Message-Id: <20200428182242.389089986@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182225.451225420@linuxfoundation.org> References: <20200428182225.451225420@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ian Abbott commit ed87d33ddbcd9a1c3b5ae87995da34e6f51a862c upstream. The DT2815 analog output command is 16 bits wide, consisting of the 12-bit sample value in bits 15 to 4, the channel number in bits 3 to 1, and a voltage or current selector in bit 0. Both bytes of the 16-bit command need to be written in turn to a single 8-bit data register. However, the driver currently only writes the low 8-bits. It is broken and appears to have always been broken. Electronic copies of the DT2815 User's Manual seem impossible to find online, but looking at the source code, a best guess for the sequence the driver intended to use to write the analog output command is as follows: 1. Wait for the status register to read 0x00. 2. Write the low byte of the command to the data register. 3. Wait for the status register to read 0x80. 4. Write the high byte of the command to the data register. Step 4 is missing from the driver. Add step 4 to (hopefully) fix the driver. Also add a "FIXME" comment about setting bit 0 of the low byte of the command. Supposedly, it is used to choose between voltage output and current output, but the current driver always sets it to 1. Signed-off-by: Ian Abbott Cc: stable Link: https://lore.kernel.org/r/20200406142015.126982-1-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt2815.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -92,6 +92,7 @@ static int dt2815_ao_insn(struct comedi_ int ret; for (i = 0; i < insn->n; i++) { + /* FIXME: lo bit 0 chooses voltage output or current output */ lo = ((data[i] & 0x0f) << 4) | (chan << 1) | 0x01; hi = (data[i] & 0xff0) >> 4; @@ -105,6 +106,8 @@ static int dt2815_ao_insn(struct comedi_ if (ret) return ret; + outb(hi, dev->iobase + DT2815_DATA); + devpriv->ao_readback[chan] = data[i]; } return i;