From patchwork Sat Nov 26 18:13:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolae Rosia X-Patchwork-Id: 9448447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AAE646077B for ; Sat, 26 Nov 2016 18:14:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3E0B26419 for ; Sat, 26 Nov 2016 18:14:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9810B26C2F; Sat, 26 Nov 2016 18:14:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 123D226C9B for ; Sat, 26 Nov 2016 18:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753513AbcKZSOf (ORCPT ); Sat, 26 Nov 2016 13:14:35 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:33204 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753418AbcKZSO0 (ORCPT ); Sat, 26 Nov 2016 13:14:26 -0500 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1cAhUX-0003OE-HF from Nicolae_Rosia@mentor.com ; Sat, 26 Nov 2016 10:14:25 -0800 Received: from rosia.mgc (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.224.2; Sat, 26 Nov 2016 18:14:24 +0000 From: Nicolae Rosia To: Lee Jones , Mark Brown , Rob Herring , Mark Rutland , Tony Lindgren CC: Liam Girdwood , Paul Gortmaker , Graeme Gregory , Baruch Siach , , , , , Nicolae Rosia Subject: [PATCH 5/5] mfd: twl: use mfd_add_devices for TWL6032 regulator Date: Sat, 26 Nov 2016 20:13:26 +0200 Message-ID: <20161126181326.14951-6-Nicolae_Rosia@mentor.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161126181326.14951-1-Nicolae_Rosia@mentor.com> References: <20161126181326.14951-1-Nicolae_Rosia@mentor.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP TWL6032 regulator driver uses the drvdata twl_priv pointer. In order to avoid accessing an invalid drvdata when the driver gets unbinded, make sure we remove the child devices before deleting the drvdata. Signed-off-by: Nicolae Rosia --- drivers/mfd/twl-core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 409b836..1e94364 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -43,6 +43,7 @@ #include #include #include +#include #include @@ -155,8 +156,16 @@ int twl4030_init_irq(struct device *dev, int irq_num); int twl4030_exit_irq(void); int twl4030_init_chip_irq(const char *chip); + static struct twlcore *twl_priv; +static struct mfd_cell twl6032_devs[] = { + { + .name = "twl6032-regulator", + .of_compatible = "ti,twl6032-regulator", + }, +}; + static struct twl_mapping twl4030_map[] = { /* * NOTE: don't change this table without updating the @@ -665,6 +674,8 @@ static int twl_remove(struct i2c_client *client) unsigned i, num_slaves; int status; + mfd_remove_devices(&client->dev); + if (twl_class_is_4030()) status = twl4030_exit_irq(); else @@ -834,6 +845,17 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) TWL4030_DCDC_GLOBAL_CFG); } + if (id->driver_data & TWL6032_SUBCLASS) { + status = mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE, + twl6032_devs, ARRAY_SIZE(twl6032_devs), + NULL, 0, NULL); + if (status != 0) { + dev_err(&client->dev, "failed to add mfd devices: %d\n", + status); + goto fail; + } + } + fail: if (status < 0) twl_remove(client);