From patchwork Mon Dec 2 10:30:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 180598 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp5012294ile; Mon, 2 Dec 2019 02:31:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzSN1Rdvvy8lB6CoqKcHEOk6zRRnW+IN1rP/U6oZQF73QlRDRKYv/u+Bzfpdc9iwCQviOxn X-Received: by 2002:a17:906:958e:: with SMTP id r14mr53289166ejx.228.1575282681274; Mon, 02 Dec 2019 02:31:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575282681; cv=none; d=google.com; s=arc-20160816; b=MDJKtL/ELsHK7F5qQLCb5Rld+SbQ8vQv/1durGuh1nNOHAiDY7lQkxb0VH7VdXS4gr SPeAs9dQ9abjukkdorsGC5ItZDF71hKcKodhctQ14k1MsroNprNnN/dJ5XWj0/z1xG6p oDqzKZe+j+N/Jfg3m1joayEp2EKeV5/9Ndyw4VgDA4gsVJYBCDGd5M8yajb8sLDSYWOo o1VPRjILNWdfEYWtMhEIQt1GARV/dBZ7a1VPEyh3zqBH7DDCj5DJtyziI7KDLkeQIE1z 7hURMlx2K88LuBpzg9SxYz1zltioXPoEMq3ltCGoqEMkptnWPcL8iL/8mv0jxrFUbiTZ hgcg== 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:to:from :dkim-signature; bh=Xu8o3osAJau1uC8uDV0Lekp3SIB/QsqNl5IGgTFKaew=; b=WraVEAtg5cMCRb0mE/nkuaeKEpSXchKXVctMdveLh3Q92PTv1K/1hIkyxWKAU4UhUG /VC4pxtts8okInZiI89GONeaxo4/tgiFMCIIWO9i54gmOz+PSKLTn99GqhGf3vQHsaTY r13e1CJapJQaqGn9z1b/iSOUtE+11lXM17vJG7bTrDkQUqZrKxuQgtlFYdhPtMuVZFkt DAyizJHEqiyxFPvAcE/a42z/tz8g420wxo8+S5HXOPaazoEhNAufm3CgkKZX5eix5aPY bUxNRU3RAV5+jlzDKxvbVa57nmSYVdbj5tBdOetQyXzDD6IlrUVYON1V4f9S67J7vSM8 60ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="o1/BVIrw"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 e21si4015152edq.191.2019.12.02.02.31.21; Mon, 02 Dec 2019 02:31:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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="o1/BVIrw"; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1727574AbfLBKbU (ORCPT + 15 others); Mon, 2 Dec 2019 05:31:20 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:37680 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727388AbfLBKbU (ORCPT ); Mon, 2 Dec 2019 05:31:20 -0500 Received: by mail-wm1-f68.google.com with SMTP id f129so22598898wmf.2 for ; Mon, 02 Dec 2019 02:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Xu8o3osAJau1uC8uDV0Lekp3SIB/QsqNl5IGgTFKaew=; b=o1/BVIrw0mQOb7BDYxrHYVuonvD2LXKai3wADGz7eqgkaUOvOU9ZKMXBaS25Hg5iT3 TUGuxna/ceRcAbe1jf/QQfABA9opeIQOyn+KBQ3RvaDiZwfXtNotw6A/PMct5E3bHQR8 redW5xCGPbLt1vqFEz7VjBATdtghKCQZOnRTu5Xe6MZlWplfJmkTtRbXcTB/lRPsbzaK 4s1ohUeJNSSHQTtOnQAsL4ii6MRTpr/17Q3qaUUatdE2ghCA9WIWEjBv7Edsh7VfZCLa n2xgBQOLClXLYPPsqLR6yEjpI1jUNlv1WwfvTLxiAG9fCqzTkPP/ukG/D2hX678tcViq PDJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xu8o3osAJau1uC8uDV0Lekp3SIB/QsqNl5IGgTFKaew=; b=JVGnFOeV31oyfTq28fQOE/Q6WIC8hASfAfaEGazjhBBSVRVUkHS51LbzspUXiJ4Si9 6Y/LvW4zzjRlkbmlsYXUORqkpJUyAHXpYPNP4XnGWWaaaIbIh6GZeK3iAFCDIfhNiNqm jEUd18nWFk6pEO7IW/78f7QdjgfrPqdMtOCOE4VsYGsmH+VV4Wyt/+mHS7Y31m56B3ay 4NUgTbfRkgph1eXBPb9s1nWR+bqAViG6P6iF3j0f/Y3Jxea+rNj1keAYfPKJOdvahvF8 dyClEPhuGhC+7Rt8XuMXsKNamJIf2hz2tLXJ1aU2OriCemC+qaGXiRkF9woq2vkeu6gl x2Bw== X-Gm-Message-State: APjAAAUoyIco7CSkuiO7gLrIq8FJ3710m+6BbdXBVgDjhva7HVsRfpXJ kUt6GPUOy1aBojgi79cgFCGRNxEOyWA= X-Received: by 2002:a1c:4483:: with SMTP id r125mr14991717wma.97.1575282678676; Mon, 02 Dec 2019 02:31:18 -0800 (PST) Received: from localhost.localdomain ([2.27.35.155]) by smtp.gmail.com with ESMTPSA id r6sm26402860wrq.92.2019.12.02.02.31.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 02:31:18 -0800 (PST) From: Lee Jones To: stable@vger.kernel.org Subject: [PATCH 4.19 11/15] pwm: Clear chip_data in pwm_put() Date: Mon, 2 Dec 2019 10:30:46 +0000 Message-Id: <20191202103050.2668-11-lee.jones@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202103050.2668-1-lee.jones@linaro.org> References: <20191202103050.2668-1-lee.jones@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Uwe Kleine-König [ Upstream commit e926b12c611c2095c7976e2ed31753ad6eb5ff1a ] After a PWM is disposed by its user the per chip data becomes invalid. Clear the data in common code instead of the device drivers to get consistent behaviour. Before this patch only three of nine drivers cleaned up here. Signed-off-by: Uwe Kleine-König Signed-off-by: Thierry Reding Signed-off-by: Lee Jones --- drivers/pwm/core.c | 1 + drivers/pwm/pwm-berlin.c | 1 - drivers/pwm/pwm-pca9685.c | 1 - drivers/pwm/pwm-samsung.c | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) -- 2.24.0 diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index c45e5719ba17..b1b74cfb1571 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -874,6 +874,7 @@ void pwm_put(struct pwm_device *pwm) if (pwm->chip->ops->free) pwm->chip->ops->free(pwm->chip, pwm); + pwm_set_chip_data(pwm, NULL); pwm->label = NULL; module_put(pwm->chip->ops->owner); diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c index 7c8d6a168ceb..b91c477cc84b 100644 --- a/drivers/pwm/pwm-berlin.c +++ b/drivers/pwm/pwm-berlin.c @@ -84,7 +84,6 @@ static void berlin_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm) { struct berlin_pwm_channel *channel = pwm_get_chip_data(pwm); - pwm_set_chip_data(pwm, NULL); kfree(channel); } diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c index a7eaf962a95b..567f5e2771c4 100644 --- a/drivers/pwm/pwm-pca9685.c +++ b/drivers/pwm/pwm-pca9685.c @@ -176,7 +176,6 @@ static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset) pm_runtime_put(pca->chip.dev); mutex_lock(&pca->lock); pwm = &pca->chip.pwms[offset]; - pwm_set_chip_data(pwm, NULL); mutex_unlock(&pca->lock); } diff --git a/drivers/pwm/pwm-samsung.c b/drivers/pwm/pwm-samsung.c index 062f2cfc45ec..3762432dd6a7 100644 --- a/drivers/pwm/pwm-samsung.c +++ b/drivers/pwm/pwm-samsung.c @@ -238,7 +238,6 @@ static int pwm_samsung_request(struct pwm_chip *chip, struct pwm_device *pwm) static void pwm_samsung_free(struct pwm_chip *chip, struct pwm_device *pwm) { devm_kfree(chip->dev, pwm_get_chip_data(pwm)); - pwm_set_chip_data(pwm, NULL); } static int pwm_samsung_enable(struct pwm_chip *chip, struct pwm_device *pwm)