From patchwork Wed Nov 28 10:43:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152243 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp923562ljp; Wed, 28 Nov 2018 02:44:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/WC+pTzsF8WrAdMr7uj8/CS2Q/7DZmSqFFYJby+dPhEBWTQFpSEU+6jIDMb2XjADPBtKpi8 X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr32630267plg.222.1543401851251; Wed, 28 Nov 2018 02:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543401851; cv=none; d=google.com; s=arc-20160816; b=VL8sfUO6GpUwLqwerm4sBw3ALmUxi1JOno7Ns27EO9O7QrapsruZkui6OhRZkXdBjE ofM8JTbxURy/csXxe+S78wKhpY7ilcr6LWYRVhG5hhdCKV8borGwBnlbPMGLtO7Qagbf 57oezHAFr7u4U9ITfejnbGWJh1Ubk/pOINYifT4mjmGCAnOIrkqgVlVeWDbDJsCkX1J5 s0Z4XAoeljvt3gZm5XeHLvi/arJVNc/q4jIvuYW/z4oO8E3h1SmdKbt+PtuzKarS6rBc k4rRV/8UKp80NcJB7szAHyssQ/yNTzry4KehHrTLp9EWFR17UYfxs7+N8AZxSvqsPQb7 Plaw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QdQV+TtwR7nUQa2nhbCkXbp692jip7xowWS6qqziPL4=; b=WuFsal10qvSv16UBBE0owOU1KaHHUo5mOdHO+oX5a/hcof28/5mJgWUlotbHrpPLRh ZPDLAqV6Lgc6sPAuH+kxH9u626TTCrrzduJKxlzA42+WV8hDLu7/hrIlTziWrnKKCcwt JxZsGkjnfIuqgER4+mzhY0cmgd8RLsF4B/unabmsvRvAOqrk05hOgf3jX4w5xVqBoFpx BpNIVRdszSZViCQXqp42r8zUwsl6IurXsZOvdCljv/GauN60mzW5dSo7L+A29oW4HYxI U/6zS9VTQmsNBqUvRnCfqspU6utho0EEGYh5gCUh6UMHRVS94I7chYl69VEPzqyPM02g axHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZMVgeJmn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o68si7293550pfo.140.2018.11.28.02.44.11; Wed, 28 Nov 2018 02:44:11 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=ZMVgeJmn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728233AbeK1VpV (ORCPT + 32 others); Wed, 28 Nov 2018 16:45:21 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42337 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728157AbeK1VpV (ORCPT ); Wed, 28 Nov 2018 16:45:21 -0500 Received: by mail-lf1-f65.google.com with SMTP id l10so18961948lfh.9 for ; Wed, 28 Nov 2018 02:44:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QdQV+TtwR7nUQa2nhbCkXbp692jip7xowWS6qqziPL4=; b=ZMVgeJmnzdhwXVO/Tc+cwfs1zPRRsyfkEXSjNq4CJulE1Y7IB3f1RF6O/Yf+Pa26eP BF4JOzEd3Q/nZc8CM+XXlATF8nZc1RYpsvTA4sxn41UAdlqkofMDwRG+vVJaWIYmeQgb vXVCIAVp+/wg7h7t/JKe222qjV155CYc9ou08= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QdQV+TtwR7nUQa2nhbCkXbp692jip7xowWS6qqziPL4=; b=IlYT8t4ohT/M66KERBZJTBcUS2b2f6itEa3mQKmIvh9AQN4JoxcuJpIH9n18yMOJpg tTyLEpn7JxqXCFfM6UsXYtDQ/L8PLLmEgpOBXzq/9VeWJtMqL7rdUBm4bU3wp6yjvrd6 JRMWgHged3dLKLmbVYj1RYkcavcc6h354Cvy93xK+ijv+iIASf8uR9MjLOnJBTYOowd8 d6azyVNWHEwKLTIriVSxoR7eh/wJAfhqCHCzpYAwYOFcqYkwxRJCPY0mklsCy9gATmCa 3HIxMbZtfhjtHELdDJ5Hc3OiPNLyl75HKdPCsOqYFmRvddHCMG3qHYuMl1B9s2ARpgOv 70gQ== X-Gm-Message-State: AGRZ1gLsuMX0tO8mHxturHQlJfSRlUcDWgE/xQbjMoclTId0MSYOPBtD 8N3XrprBCgoSu7non+z3j4fnfQ== X-Received: by 2002:a19:5e5d:: with SMTP id z29mr20746732lfi.105.1543401846138; Wed, 28 Nov 2018 02:44:06 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id c20sm1095101lfj.67.2018.11.28.02.44.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Nov 2018 02:44:05 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Linus Walleij Subject: [PATCH 05/10] regulator: max8973: Let core handle GPIO descriptor Date: Wed, 28 Nov 2018 11:43:45 +0100 Message-Id: <20181128104350.31902-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181128104350.31902-1-linus.walleij@linaro.org> References: <20181128104350.31902-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fixes: e7d2be696faa ("regulator: max8973: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- drivers/regulator/max8973-regulator.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e7a58b509032..6e11324cb9cf 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -632,7 +632,7 @@ static int max8973_probe(struct i2c_client *client, struct max8973_chip *max; bool pdata_from_dt = false; unsigned int chip_id; - struct gpio_desc *gpiod; + struct gpio_desc *gpiod = NULL; enum gpiod_flags gflags; int ret; @@ -759,9 +759,9 @@ static int max8973_probe(struct i2c_client *client, else gflags = GPIOD_OUT_LOW; gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE; - gpiod = devm_gpiod_get_optional(&client->dev, - "maxim,enable", - gflags); + gpiod = gpiod_get_optional(&client->dev, + "maxim,enable", + gflags); if (IS_ERR(gpiod)) return PTR_ERR(gpiod); if (gpiod) { @@ -798,6 +798,8 @@ static int max8973_probe(struct i2c_client *client, ret = max8973_init_dcdc(max, pdata); if (ret < 0) { + if (gpiod) + gpiod_put(gpiod); dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); return ret; } @@ -811,6 +813,8 @@ static int max8973_probe(struct i2c_client *client, /* Register the regulators */ rdev = devm_regulator_register(&client->dev, &max->desc, &config); if (IS_ERR(rdev)) { + if (gpiod) + gpiod_put(gpiod); ret = PTR_ERR(rdev); dev_err(max->dev, "regulator register failed, err %d\n", ret); return ret;