From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lithops.sigma-star.at (mailout.nod.at [116.203.167.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EF9035A380; Thu, 26 Feb 2026 18:36:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.167.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772131020; cv=none; b=twnGu3WPQtUGHlFYx0He09MzAtnaKgmqdVSuZ6/ifL0/GKLAQRBhkmhL9eZ6I/kWCn+TDX/TAZDqOivj7yxu6BhhSMVxiyQCkL0IMbZi2B6E2UAbawfOUj5JzfCz/AALBpRD0ZT1sVcbIO1k2meHSbTS4ZVaA/ycWOA5I6p0mJA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772131020; c=relaxed/simple; bh=sRRUHQ8nku8SZqHBNBcQg7fQm60OhaMpWK267Bn6/b4=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: MIME-Version:Content-Type; b=M5RTBlYcQQQ8315SmPIOwHnUAmGK0tgKCTE+6S1N62s7S3Kot/Zf1C/jIS1Ik7QrBQEvYehbW/VmQGStDE3MvFwT1kjXbyiGvYk9OlHzNaxcmpku47b7ncZExYG1r6/86C9mc7B+SgidU6ILqxq7313dXgERPhkMvCo+E/lcYrs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at; spf=fail smtp.mailfrom=nod.at; arc=none smtp.client-ip=116.203.167.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nod.at Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id BE9CE298580; Thu, 26 Feb 2026 19:36:45 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id MaL9rZlZo95P; Thu, 26 Feb 2026 19:36:45 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 2EF7B298599; Thu, 26 Feb 2026 19:36:45 +0100 (CET) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id L2wQ0dmSl527; Thu, 26 Feb 2026 19:36:45 +0100 (CET) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id EA45C298580; Thu, 26 Feb 2026 19:36:44 +0100 (CET) Date: Thu, 26 Feb 2026 19:36:44 +0100 (CET) From: Richard Weinberger To: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= Cc: linux-kernel , linux-pwm@vger.kernel.org, linux-hwmon , Guenter Roeck , julian friedrich Message-ID: <1212284023.1388.1772131004601.JavaMail.zimbra@nod.at> In-Reply-To: References: <20260225125159.20822-1-richard@nod.at> Subject: Re: [PATCH] [RFC] hwmon: nct6775: Register fan PWMs as PWM chip Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF147 (Linux)/8.8.12_GA_3809) Thread-Topic: hwmon: nct6775: Register fan PWMs as PWM chip Thread-Index: a2FkoSPj2isBvD2uWv71j3ga/gQkdA== Hello Uwe, ----- Urspr=C3=BCngliche Mail ----- > Von: "Uwe Kleine-K=C3=B6nig" >> +=09struct nct6775_data *data =3D pwmchip_get_drvdata(chip); >> +=09const u8 *wfhw =3D _wfhw; >> + >> +=09if (get_pwm_period(data, pwm->hwpwm, &wf->period_length_ns)) >> +=09=09return 1; >=20 > That looks wrong. In principle nct6775_pwm_round_waveform_fromhw() > doesn't depend on hardware state. It's supposed to just convert the > settings stored in _wfhw to wf. If you know that some things are > constant during the lifetime of the PWM and you read those from > hardware, return a proper error code, not 1. I see. Since the frequency is never changed by the driver we could read it while probing and use here the cached value. > Rounding down wf->period_length_ns is fine, so this must be: >=20 >=09if (wf->period_length_ns < cur_period) >=09=09return 1; But then the period is no longer fixed and something larger than supported can get configured. Smaller values get caught, though. e.g. root@fedora:/sys/class/pwm/pwmchip0/pwm2# cat period=20 43243 root@fedora:/sys/class/pwm/pwmchip0/pwm2# echo 43200 > period=20 bash: echo: write error: Invalid argument root@fedora:/sys/class/pwm/pwmchip0/pwm2# echo 50000 > period=20 root@fedora:/sys/class/pwm/pwmchip0/pwm2# echo $? 0 Thanks, //richard