Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2634333pxj; Mon, 14 Jun 2021 03:37:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn2hKZOYR3PmP/xNA2cYKTWEFTfkfiA7F2ABo+SDuAnNashtlBVRlKninN2MHzg7W3VYWB X-Received: by 2002:a05:6402:11c9:: with SMTP id j9mr16440337edw.89.1623667021540; Mon, 14 Jun 2021 03:37:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623667021; cv=none; d=google.com; s=arc-20160816; b=CtMtdcKrZwytqNq52QcU+xvvI2HCLv9tU6IuwMOBwWqqALkUgwXbykNvHf0Nh+JBgA 3nRyJ7HSKSq8f2geVce93ptfd898FC+D2UpzrLYhwGmYy1UuI8JjN1uM7wK7keYO1Exp UM3epEE39eQbBNwpbKhpttqxyfxED0PWYYYBF0XudA2J9RhWIbZmoHQcv0T4jQeMxGx3 L7GPduDWc+b+X+3dF4Mvae9gx8y+/p6h8NplT0FQoFZ3r13e2xscq2qMDhiJ5UP0LKkX 9N9kz5JchcYxhhS/ZmynKqv1YNNG8wsXOd525xU5029rEcaIJlMTb+W+wFCXq1GleQYi vCNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KXE7TQu4LC5kSCXacc6xBIiZPhnHsfDTUn+r5KVBuTQ=; b=UrCNBGXwAbyJQynhGXIKtTQycUWWWNfD+RJ5U7At5lK1RmldT8DP9aCp3JAZsFCO0w LiffFsKmqBDG5L39gWfXJmtGzxoD9LaFdWSJx9sddDk8YqLkon9PklztSk8rPzBn4vm0 DWii/L07MYfJrP0c4w7wRtMDRCl1nlqXkyzHAKFHQeu1Eh7QxWJ8PiQWvpC4qBbV5r+3 k6n3Z2H7mz8lQc/mKWSCKCPo47mNNdmcLNHY2WwzVCrV2caBVjCsaLs4bK9BKGKdWA9g GMX/K+N0FUiqF6DmJBV1YxvDmhGeX6jxbKSBuxlT7b4LqBzMpacHp2PsNSwf4jdJLzZ5 K3Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2JSn8fN9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dz7si10779075edb.68.2021.06.14.03.36.39; Mon, 14 Jun 2021 03:37:01 -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=@linuxfoundation.org header.s=korg header.b=2JSn8fN9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233055AbhFNKe6 (ORCPT + 99 others); Mon, 14 Jun 2021 06:34:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:39656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233158AbhFNKc5 (ORCPT ); Mon, 14 Jun 2021 06:32:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 180A7613B2; Mon, 14 Jun 2021 10:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623666642; bh=thdStqXD+ZMNrxSkCYmLPOSGcB5B7NAfKuA6O3rz4io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2JSn8fN9DCGvCvQ6ZJufrHGBxASKzI+J8HrV4o8KEl4R7mzGKg5hiv4dolFkeKINi 2GRDSeFjNBcLHD14KCBHOx5Qz0KxJoT1wDsAURy/i/XpoacRNCwLlzLmljIayyvuf2 QXYvcAtt4bnI7ehmZwW+EHdky+XomoinsUQ3ihLA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Packham , Wolfram Sang , Sasha Levin Subject: [PATCH 4.9 19/42] i2c: mpc: Make use of i2c_recover_bus() Date: Mon, 14 Jun 2021 12:27:10 +0200 Message-Id: <20210614102643.315217456@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102642.700712386@linuxfoundation.org> References: <20210614102642.700712386@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Packham [ Upstream commit 65171b2df15eb7545431d75c2729b5062da89b43 ] Move the existing calls of mpc_i2c_fixup() to a recovery function registered via bus_recovery_info. This makes it more obvious that recovery is supported and allows for a future where recovery is triggered by the i2c core. Signed-off-by: Chris Packham Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-mpc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 565a49a0c564..afbbdc79c173 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -581,7 +581,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { writeb(status & ~CSR_MAL, i2c->base + MPC_I2C_SR); - mpc_i2c_fixup(i2c); + i2c_recover_bus(&i2c->adap); } return -EIO; } @@ -617,7 +617,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { writeb(status & ~CSR_MAL, i2c->base + MPC_I2C_SR); - mpc_i2c_fixup(i2c); + i2c_recover_bus(&i2c->adap); } return -EIO; } @@ -632,6 +632,15 @@ static u32 mpc_functionality(struct i2c_adapter *adap) | I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL; } +static int fsl_i2c_bus_recovery(struct i2c_adapter *adap) +{ + struct mpc_i2c *i2c = i2c_get_adapdata(adap); + + mpc_i2c_fixup(i2c); + + return 0; +} + static const struct i2c_algorithm mpc_algo = { .master_xfer = mpc_xfer, .functionality = mpc_functionality, @@ -643,6 +652,10 @@ static struct i2c_adapter mpc_ops = { .timeout = HZ, }; +static struct i2c_bus_recovery_info fsl_i2c_recovery_info = { + .recover_bus = fsl_i2c_bus_recovery, +}; + static const struct of_device_id mpc_i2c_of_match[]; static int fsl_i2c_probe(struct platform_device *op) { @@ -735,6 +748,7 @@ static int fsl_i2c_probe(struct platform_device *op) i2c_set_adapdata(&i2c->adap, i2c); i2c->adap.dev.parent = &op->dev; i2c->adap.dev.of_node = of_node_get(op->dev.of_node); + i2c->adap.bus_recovery_info = &fsl_i2c_recovery_info; result = i2c_add_adapter(&i2c->adap); if (result < 0) -- 2.30.2