From patchwork Wed Sep 28 08:15:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 676044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3skVry3LrVz9sC3 for ; Wed, 28 Sep 2016 18:16:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751686AbcI1IQA (ORCPT ); Wed, 28 Sep 2016 04:16:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36540 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbcI1IP4 (ORCPT ); Wed, 28 Sep 2016 04:15:56 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 027643F1F3; Wed, 28 Sep 2016 08:15:56 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-116-65.ams2.redhat.com [10.36.116.65]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8S8FoBj031570; Wed, 28 Sep 2016 04:15:54 -0400 From: Benjamin Tissoires To: Jean Delvare , Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/10] i2c: i801: store and restore the SLVCMD register at load and unload Date: Wed, 28 Sep 2016 10:15:41 +0200 Message-Id: <1475050549-25542-3-git-send-email-benjamin.tissoires@redhat.com> In-Reply-To: <1475050549-25542-1-git-send-email-benjamin.tissoires@redhat.com> References: <1475050549-25542-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 28 Sep 2016 08:15:56 +0000 (UTC) Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Also do not override any other configuration in this register. Signed-off-by: Benjamin Tissoires --- no changes in v3 new in v2 --- drivers/i2c/busses/i2c-i801.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index b494a85..7334831 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -240,6 +240,7 @@ struct i801_priv { struct i2c_adapter adapter; unsigned long smba; unsigned char original_hstcfg; + unsigned char original_slvcmd; struct pci_dev *pci_dev; unsigned int features; @@ -952,7 +953,12 @@ static int i801_enable_host_notify(struct i2c_adapter *adapter) if (!priv->host_notify) return -ENOMEM; - outb_p(SMBSLVCMD_HST_NTFY_INTREN, SMBSLVCMD(priv)); + priv->original_slvcmd = inb_p(SMBSLVCMD(priv)); + + if (!(SMBSLVCMD_HST_NTFY_INTREN & priv->original_slvcmd)) + outb_p(SMBSLVCMD_HST_NTFY_INTREN | priv->original_slvcmd, + SMBSLVCMD(priv)); + /* clear Host Notify bit to allow a new notification */ outb_p(SMBSLVSTS_HST_NTFY_STS, SMBSLVSTS(priv)); @@ -961,12 +967,11 @@ static int i801_enable_host_notify(struct i2c_adapter *adapter) static void i801_disable_host_notify(struct i801_priv *priv) { - if (!(priv->features & FEATURE_HOST_NOTIFY)) return; /* disable Host Notify... */ - outb_p(0, SMBSLVCMD(priv)); + outb_p(priv->original_slvcmd, SMBSLVCMD(priv)); /* ...and process the already queued notifications */ i2c_cancel_smbus_host_notify(priv->host_notify); }