Received: by 10.213.65.68 with SMTP id h4csp548453imn; Fri, 30 Mar 2018 10:29:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx48PX5Hp17OBPGmGKBp7wesijhup9DYHaIzI0e5+zjQEF5NsmiibZCVjCt2qvJSa3wTiTNhp X-Received: by 2002:a17:902:820a:: with SMTP id x10-v6mr13743271pln.105.1522430968600; Fri, 30 Mar 2018 10:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522430968; cv=none; d=google.com; s=arc-20160816; b=aRyxfeaYBMqRhu2bhQFZoRtcL4XUfoSYBKqkaDep9xV9Lz0rYF+4K6s5njGrtofgCb ZT65J3HfpRmlf84ZXECNhQiJpDpkcWTQFqhjWwGj/1XzkZBOg6J3FaKZjXhTEWjn221M 9qqJpV9SIScaWrybqLb8GlAujWoUuPDLiaDz3w8F4sAd5UGLQp3myO9YFc6b/ZA+1fS/ tnCHtCqX8i6tVILfrWCajKjgN4E/AACTPjOYO6mk0kIwj012XbZhykPLc3XSjAbnoqP3 99ZFixKJy7+oJGuX56WSp1RWzKsruxyi/pq3LFVNKiYayF5fYF42EIfzo0UH+N8yjS9K h0qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=qwa5rCgTzfPYS6M6MjsqDYQu2NGKmVrYwgk7xsGM1AM=; b=RHlUumP6prHP0/Qvf1604A0LMe5Yp3SIocKDGVeHKxIA2VW+VFpJcprQkazkCUsgVe Mb5ahWdXQmvH7AwOyMVdrGanYJ3DDcoOoFgmdL7o73yhwMdQSajRzA8zEiF5StzpiXBU sRAStbegAE9b3qYNAOruNdE9cs77EqZmOkVP2b4YhoJ2k76fWejPoeChLF81e7o9SW7r rH8NMMy/atRzf/32t5lIaVBOCWoq2FFk28j7u9GgnjOOiMoWlGN1Td2nMnPn7bnlvAM9 oS5NVFnig+4fKZUNiBbkBO9jxI+AIE9TbyD0GLKvt6FLsCh8USK7Pglhy8LFNBomZ2y1 UTkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si6680605pfb.204.2018.03.30.10.29.15; Fri, 30 Mar 2018 10:29:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752538AbeC3RYa (ORCPT + 99 others); Fri, 30 Mar 2018 13:24:30 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58916 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752455AbeC3RY1 (ORCPT ); Fri, 30 Mar 2018 13:24:27 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id D9099276443 From: Sebastian Reichel To: Sebastian Reichel , Milo Kim , Lee Jones , Daniel Thompson , Rob Herring , Tony Lindgren Cc: Jingoo Han , Mark Rutland , linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, devicetree@vger.kernel.org, linux-omap@vger.kernel.org, Sebastian Reichel Subject: [PATCHv4 03/10] mfd: ti-lmu: use managed resource for everything Date: Fri, 30 Mar 2018 19:24:07 +0200 Message-Id: <20180330172414.26575-4-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180330172414.26575-1-sebastian.reichel@collabora.co.uk> References: <20180330172414.26575-1-sebastian.reichel@collabora.co.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This replaces all remaining unmanaged resources with device managed ones, so that the remove function is no longer needed. This makes the code slightly shorter and fixes two problems: 1. The hardware is disabled after the child devices have been removed. Previously there was a potential race condition. 2. The hardware is disabled when mfd_add_devices fails during probe. Signed-off-by: Sebastian Reichel --- drivers/mfd/ti-lmu.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/mfd/ti-lmu.c b/drivers/mfd/ti-lmu.c index e14cb9f41b44..2ee09d099832 100644 --- a/drivers/mfd/ti-lmu.c +++ b/drivers/mfd/ti-lmu.c @@ -47,8 +47,9 @@ static int ti_lmu_enable_hw(struct ti_lmu *lmu, enum ti_lmu_id id) return 0; } -static void ti_lmu_disable_hw(struct ti_lmu *lmu) +static void ti_lmu_disable_hw(void *data) { + struct ti_lmu *lmu = data; if (lmu->en_gpio) gpiod_set_value(lmu->en_gpio, 0); } @@ -205,6 +206,10 @@ static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id) if (ret) return ret; + ret = devm_add_action_or_reset(dev, ti_lmu_disable_hw, lmu); + if (ret) + return ret; + /* * Fault circuit(open/short) can be detected by ti-lmu-fault-monitor. * After fault detection is done, some devices should re-initialize @@ -214,17 +219,8 @@ static int ti_lmu_probe(struct i2c_client *cl, const struct i2c_device_id *id) i2c_set_clientdata(cl, lmu); - return mfd_add_devices(lmu->dev, 0, data->cells, - data->num_cells, NULL, 0, NULL); -} - -static int ti_lmu_remove(struct i2c_client *cl) -{ - struct ti_lmu *lmu = i2c_get_clientdata(cl); - - ti_lmu_disable_hw(lmu); - mfd_remove_devices(lmu->dev); - return 0; + return devm_mfd_add_devices(lmu->dev, 0, data->cells, + data->num_cells, NULL, 0, NULL); } static const struct i2c_device_id ti_lmu_ids[] = { @@ -240,7 +236,6 @@ MODULE_DEVICE_TABLE(i2c, ti_lmu_ids); static struct i2c_driver ti_lmu_driver = { .probe = ti_lmu_probe, - .remove = ti_lmu_remove, .driver = { .name = "ti-lmu", .of_match_table = ti_lmu_of_match, -- 2.16.2