Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp895808lqt; Fri, 7 Jun 2024 01:45:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2NX4bLZjqV2QBO46GlW2lBshr1R1qbJjsei/RhSvKt7aDbCSMcocpTswal4g1g1aWQ8YtPGYQuDg+PzCqaptpnM+w8E5PdAIqr5qCCw== X-Google-Smtp-Source: AGHT+IG8uWXv7GpIEbmp/c9nXWn6nN7/Ixy2KlkOAY9/dF6OhR5doarXkCq3v1usZQK8Mt43d2MD X-Received: by 2002:a05:6a20:7fa9:b0:1af:ac8c:4366 with SMTP id adf61e73a8af0-1b2e784ae7bmr2351000637.30.1717749934367; Fri, 07 Jun 2024 01:45:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717749934; cv=pass; d=google.com; s=arc-20160816; b=jUzqObYHCfBtGhHHHVJrMzHFD/grq2n/jVaSqJGKGw9LA19kIliD6iOGnHQIZWVYIn yqwCEtzOWhl3zg9ZFs5GXucuS21+s71B6Ti/6TxXyiN4thSFNzd50MHuZxQ3zOJB4Hot LGHt6zsWk3ltUxKCtCUbPfjTX3Wr+eNnY+gEZq+LNTcdQnIaDq9tifIPRP4N1bqsntb6 7q+3LmjSqJYd7wXvT0qeBpwHDfxM7lckojRhzhBH91qlPFmxSD03J9an0pzc9qdDsg7d eT59HxgCBGZwHj59EP9UjcB9W5n8s4Ed0IJXa/kWkYeAG3sWfiN+VTzo0xiTrchrVfJI xaYw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=5FGL8cAEQ0O2enVmYyGVM2Jx+NaXP9rfnR5x0k/WELA=; fh=aohNsjDD2XJ4WWmQk67kAWX/HarDs1FrEwoGzsDG7eQ=; b=SDRTrDOz9y97ixk9saH1WUB3L/FgVbz88B2ZJGYPewErGSKJ8OC0I2kTbBgQLc9QGj UCW3aJ22RkJ8wN5zlFfZodXZWgcUOnqagtVdAgf5eZvrBYsO0/Sw5MOvtzepPVMvSju6 cZ7R8o9gIZzDiwFTgTuH6e335UFV9a00rF3ucL6hPNJX3q+rMlXH2Ea6CyhT6LPhGh1d ZhmO3N7KxGT8lKxUuZHb3jnqbhch2kG6aRBL2tyRPhKdvmW4tkTcoWfvkL64qTUiddAG gOK22wrU4ApYE7FbKxeyVF+/lV10kB91/RWtxScps2si3avlxJm17MCltUAg64MKoHmA 8lag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=WRYkQq3C; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-205626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205626-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2ae104d8si2584583a12.887.2024.06.07.01.45.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 01:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=WRYkQq3C; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-205626-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205626-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8A039281F7D for ; Fri, 7 Jun 2024 08:45:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7044D15B150; Fri, 7 Jun 2024 08:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="WRYkQq3C" Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 553EF15B109 for ; Fri, 7 Jun 2024 08:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717749892; cv=none; b=NT+KLMDOboJfvoYyru/L5a+5JzgeRxkm+eGMU29BjfTNLRYrh7shFxcTZMtD0NARgcnHXjfOvobF9xkjDyJmugj6aLNPTHWNM4bfxIphmFQQxKJ6QQiUjcOORKM1HNYvi5sMQ13pIp1FDJQOXhK5OxpeNrHKUFYIA/PaCamCLaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717749892; c=relaxed/simple; bh=wudYmHy3qCSrWLSreH+1TgxgneyUtA3ewiC9lXDQSKs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ple3pvvwQBTIhgJITD7mhIypDaOZrOXllyEMB500SVJ4QmjFji2Ol13Hf/3x2sYQEdT7jcygUcWas0s5hk8eKNSALE0ckate2TNyx5MY2OhmAiRfm8asFjU+AvD83xytjOWe0eqiS7m4yX/1JrO/dgn+9eaB1rrv1X/5WZ6FG4s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=WRYkQq3C; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-42160f2dc32so9975305e9.3 for ; Fri, 07 Jun 2024 01:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1717749888; x=1718354688; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5FGL8cAEQ0O2enVmYyGVM2Jx+NaXP9rfnR5x0k/WELA=; b=WRYkQq3Cw2ZkjAGEjYa0qecOxF1FIZEIprx0xpD9syTdNHTT6U0e4F1Nrp6MwYcDml tyToYTqhZFpNt+r/f2aSfqHECjiQk30EzxcFBs9dUyaKfPG0LyU1v/lbAUm56qnyJEhD YuTsOwrWPwlNbpLoJFP0Oxkxaz3s0QEcZSc9VOH49FvSWfLTxV/tNCkF10eRVwkbQ4Wv yqJfTt585tX9K176GFcNEoS/Ofi7UKU3Ll/6B8gt9QFYrF4ccaQbGTzX/Z5MrxqPGpfF Bia1NmsdX/HH1mnY6B3VIg08gCLAdrCJJItVYSHVHBKoAaxVACj8kS1O1+lyiZ4oTzbb DeFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717749888; x=1718354688; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5FGL8cAEQ0O2enVmYyGVM2Jx+NaXP9rfnR5x0k/WELA=; b=SZqZ8CNwRXkWhkGQHNeydXLRsTkiSzUhbvzoO6GSP5fXUWWpaA1gtSZ3KABLcotBpX 886ws4ZMuScPGTxAyzUZZi/4H2VFfEM1qh2cePxIk4zrn4NhlzU+CdAGU6alsv8M8qBi 5F6h30HJDCyBifxp59/Ku0laH3u5C78nvmB+zJlUmBNjNGTNdtm2d+6tPn/I3QQdBGOh jmpLu3PoNSXRP+jH+waR/W3kvw3uMyGC2QShRy95PnPmCT8aq0Hmw/TJx5ORo0W6Otpn Ly1ob5/CTK/4I2rJJYhlZT6nYPilucIx/smkgbYIC52vBjdklECVsEYeSsqnP95Lmprs Daxg== X-Forwarded-Encrypted: i=1; AJvYcCWTPGK4pcxqN7aCn1FeeLFSL4dw5ikBsgJvPg8YXmSAsqG85nzl/J18bMqWrtQWnLK+cHOGmsfvAW4UoEGK0K+CkL9tEjfpaRSh9tzn X-Gm-Message-State: AOJu0YypB2Uq2T4RWTQaPUlV/OylO4kRFK5Lb93bqyxw1DRNq7ty1VAD TpsVyvfBJ830miaIZmVI06cAZIO5pQSFVuSR0WcFdC+nFUJPtGGCJLwXv7hqPP4= X-Received: by 2002:a05:600c:450e:b0:418:5ed2:5aa6 with SMTP id 5b1f17b1804b1-42164a3b0f0mr19195415e9.31.1717749887864; Fri, 07 Jun 2024 01:44:47 -0700 (PDT) Received: from localhost (p509153eb.dip0.t-ipconnect.de. [80.145.83.235]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215814e7bfsm80098415e9.40.2024.06.07.01.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 01:44:47 -0700 (PDT) From: "=?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Benson Leung Cc: Guenter Roeck , linux-pwm@vger.kernel.org, chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] pwm: cros-ec: Don't care about consumers in .get_state() Date: Fri, 7 Jun 2024 10:44:15 +0200 Message-ID: <20240607084416.897777-6-u.kleine-koenig@baylibre.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240607084416.897777-5-u.kleine-koenig@baylibre.com> References: <20240607084416.897777-5-u.kleine-koenig@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=3061; i=u.kleine-koenig@baylibre.com; h=from:subject; bh=wudYmHy3qCSrWLSreH+1TgxgneyUtA3ewiC9lXDQSKs=; b=owEBbQGS/pANAwAKAY+A+1h9Ev5OAcsmYgBmYshl2TygktlmNS6vtWgQA7+2Bnh2F7OPpd1Z2 OFVxplP1LiJATMEAAEKAB0WIQQ/gaxpOnoeWYmt/tOPgPtYfRL+TgUCZmLIZQAKCRCPgPtYfRL+ TjbTCACR1DiLfufuRbJltZvAy1vOOWnfILZW6Txf383BpkW755Jry1cQfC4l0KE2mqgXI9FRLmk +YL7nbP+5arxci4Hq8p1PEv1B5C9BUP7z1Xq1mk0ZlpLbBm+jGk2D9gZR71WquJp1KJfonHDd0l mGksY7Bl6kwFNrhtqRdy+JuNMQLpb7yHspr+Afm08DNYqlL8ncrTPkN+X8yiuOs9z7ZsMbt8P+1 HoHxCaKPXTW1XBXckJzT6Bpt/FaiyedOk8g/cWakA2TSctd540/d3pfiQZj6X+vspclmmkde34s z/77KO/ajGmZUu9utoA/V8bGYdIurzFPY5AUGuuRXUVu4fNB X-Developer-Key: i=u.kleine-koenig@baylibre.com; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit The get_state() callback is never called (in a visible way) after there is a consumer for a pwm device. The core handles loosing the information about duty_cycle just fine. Simplify the driver accordingly. Signed-off-by: Uwe Kleine-König --- drivers/pwm/pwm-cros-ec.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/drivers/pwm/pwm-cros-ec.c b/drivers/pwm/pwm-cros-ec.c index 606ccfdaf4cc..ba4ee0b507b7 100644 --- a/drivers/pwm/pwm-cros-ec.c +++ b/drivers/pwm/pwm-cros-ec.c @@ -25,15 +25,6 @@ struct cros_ec_pwm_device { struct cros_ec_device *ec; bool use_pwm_type; - struct cros_ec_pwm *channel; -}; - -/** - * struct cros_ec_pwm - per-PWM driver data - * @duty_cycle: cached duty cycle - */ -struct cros_ec_pwm { - u16 duty_cycle; }; static inline struct cros_ec_pwm_device *pwm_to_cros_ec_pwm(struct pwm_chip *chip) @@ -135,7 +126,6 @@ static int cros_ec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) { struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip); - struct cros_ec_pwm *channel = &ec_pwm->channel[pwm->hwpwm]; u16 duty_cycle; int ret; @@ -156,8 +146,6 @@ static int cros_ec_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, if (ret < 0) return ret; - channel->duty_cycle = state->duty_cycle; - return 0; } @@ -165,7 +153,6 @@ static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) { struct cros_ec_pwm_device *ec_pwm = pwm_to_cros_ec_pwm(chip); - struct cros_ec_pwm *channel = &ec_pwm->channel[pwm->hwpwm]; int ret; ret = cros_ec_pwm_get_duty(ec_pwm->ec, ec_pwm->use_pwm_type, pwm->hwpwm); @@ -175,23 +162,10 @@ static int cros_ec_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, } state->enabled = (ret > 0); + state->duty_cycle = ret; state->period = EC_PWM_MAX_DUTY; state->polarity = PWM_POLARITY_NORMAL; - /* - * Note that "disabled" and "duty cycle == 0" are treated the same. If - * the cached duty cycle is not zero, used the cached duty cycle. This - * ensures that the configured duty cycle is kept across a disable and - * enable operation and avoids potentially confusing consumers. - * - * For the case of the initial hardware readout, channel->duty_cycle - * will be 0 and the actual duty cycle read from the EC is used. - */ - if (ret == 0 && channel->duty_cycle > 0) - state->duty_cycle = channel->duty_cycle; - else - state->duty_cycle = ret; - return 0; } @@ -291,11 +265,6 @@ static int cros_ec_pwm_probe(struct platform_device *pdev) chip->ops = &cros_ec_pwm_ops; chip->of_xlate = cros_ec_pwm_xlate; - ec_pwm->channel = devm_kcalloc(dev, chip->npwm, sizeof(*ec_pwm->channel), - GFP_KERNEL); - if (!ec_pwm->channel) - return -ENOMEM; - dev_dbg(dev, "Probed %u PWMs\n", chip->npwm); ret = devm_pwmchip_add(dev, chip); -- 2.43.0