Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2793526rdb; Mon, 5 Feb 2024 19:26:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGl+DND1BTX8DFp1R6tWgDd0DKYVbpPh1wcpQLZl7GREgFf4HHD44Dg5zWb/4hFs5IUsvqk X-Received: by 2002:a17:906:7d83:b0:a37:a66b:b361 with SMTP id v3-20020a1709067d8300b00a37a66bb361mr535863ejo.21.1707189980103; Mon, 05 Feb 2024 19:26:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707189980; cv=pass; d=google.com; s=arc-20160816; b=A+3Jk033pb5bCZe9SyeV/nzdKBE0mkP7K+i4UX6Ta4vu5S1pYYmsXY489ITmyu+Xmf C/WakpPsXLH89zcNgtYXKbI7fXbS+XNv6aifHkBHd43lH02RW4li8cPEyYr9pOrJKfiW nfd1Yf9t9f9X8Ye9QLLxZHCvEt3lHPJuLc8tk/ixw1c2X85ejpofNIc1M4PeWCUXdeLk LJfDTE2qnNoz99xurSfjqj7f4EmOfrGsZZfCsrxD5lFr7vxb9Hw7Oty3Wjo0fmAHYHsX 8D6HakYSu7k6UP/TXOatd4tUI3ytzkiu8LGQIQD7TE//03mIM7cuW6f7S+qiQ/6d1mJ2 fCuQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :sender:dkim-signature; bh=XZfzzDXmxicnToftyCXmWq7bV7IDNDJptxpK3iKTrk4=; fh=iyguiKL+c1hki1DPnP+ECt5OoAY5Qhdi0gJ5D7R1K58=; b=SqZKSYtOvWmT+dbqHg0eW8O/FRYLWVzTp+ssPlfWXzpLu7uHKa0IrFZR9kC0x9/p1X ujvnsaoM9qK8y6EyKMyTSyoJ6ab/ZyN3NDAOPQvF2Uq7UUCwDIuLm/AcjgFo8ytnnQwS 6kVHfvtgHCWwlZ9BwQW9mP8fnYiSxdY+aVz0Zn/+HLyw0YB8a0stgGBqG2X6u5P4ij7u KnYney/PjGdAmFZ97As6v5si73TaMCdbbSwTLm4XvsUWrvj2xaCMTcpHtPDk2CoOFe7f 96y53sSp6RrEtEFkpZZC45RjHNWQhtAamRn673Dxsq2OZgXcvR09waVoBjDdKATxstaj bHZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VFxLB2C3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-54252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54252-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWrh31TgLgbNe6Ch0KXFHg3bA8hDNtchPxLO/WA6ykRmI/YMuAYNwDKYZa0OiY4JHUo4oJHE8ZGeblco/pzUoO5pE/Cvq9+H1cxMziSNQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gx10-20020a170906f1ca00b00a37adf0582esi563975ejb.603.2024.02.05.19.26.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 19:26:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VFxLB2C3; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-54252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54252-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A53111F238FA for ; Tue, 6 Feb 2024 03:26:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B3CC745C5; Tue, 6 Feb 2024 03:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VFxLB2C3" Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 9CF156E2B0; Tue, 6 Feb 2024 03:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707189969; cv=none; b=sQe1BHLI8rrkuI5buQlvXe89Dnm15NZ8MqptzYAnWyla0WXBijPTh8P+UuEKecaae//XfdE+VvAIXS0gc/k/xC1RZrT3AYYxUvwJ3E2JGl7uYquaQVYTKR+nOY5Q/ZSQXYeBpcT2drayZPPgqUXSVtTEvmXlZg8WauvIOi9G0FQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707189969; c=relaxed/simple; bh=umEb0BhqMX8QgLQWlM++IWcTd98YG6V+w+9Y6bL6Kz8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UWeT/jdtyHVGo0YQ6OmOjXa52TT0HTqudqRw05Ppu14bqekAaKbCAkOllp2aSzSbut99YSEgSUkXqhn7nLy1aqhvqUpVuAtUVtonPj7cmcT8KlOY4DWOrntYTqFZGzGNCxaZ1jFhimR2WnzL/esy/+3PmiwJzFglW/1VFc+vdpk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VFxLB2C3; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so387736a12.0; Mon, 05 Feb 2024 19:26:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707189967; x=1707794767; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=XZfzzDXmxicnToftyCXmWq7bV7IDNDJptxpK3iKTrk4=; b=VFxLB2C3auGDmBYnck2VQxQ0zp/pWl61WhynTTrh5CIUGtu9gIr1FWHYU9QuBafYkL hv39wGvaX8oMGrlGUt3tdDD5Khy5Gsup/SwddFk8g+8AwCb+roN3MnYnTEzlbpH4gMgs JGwdTCiGmBWx91IvF996riEB3hBod5vJM8HPk3COk/hM4WgYz+aJ9HYw2MYqZi5dNAoI SKWbwfNgZvlUwoF2+Zo1nbFLCE4IaktVtDCnveNdl7FWvWUHYZ6OHXHF1CR1eLox3vdW hATpv1H8IntFJtAcshCpr4sC2jOytVWf4RwmWp3hisMN6p/j4h18pY4TFmCgLT2pzJPb afXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707189967; x=1707794767; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XZfzzDXmxicnToftyCXmWq7bV7IDNDJptxpK3iKTrk4=; b=XFOUX2XE9syaY7qnrbKWhBsxPInlUHNhdfwJWnfRvat0GZqxGdGmiyfRaD80l6EZec jlPLCi724VTQuuuRLKq3W2VXMRk1RWeGjttgxysTymFuzYkLY5YK2B1as93oVCu3Zut/ KlM2U6/Pk2n6pCzSGymIdnfGuhcF6yP2YdE8O0fj2VAOUNhu/4btrSHZ239L8ty7mAvl xhMu1H0Kbz99U7CxacmSLDUuWGUE/0cNHIqBrkjOVX+tSAtw0Gq1lY8FB2qG4Q1C1sZq /7iXt0ODFTJ6yGDaY0fbcRluKMPZUKmP0u9N0XUSd3pu0mzGmRY4iwvChhBIexqFtLkI GTRQ== X-Gm-Message-State: AOJu0YxbtZte8CMU5LZsN7b6vzta2fqXNtH6tDk0qBAvV+xS8QZkB9Iu MkFuo0bozqNFw4YLwEyh/Z6jwtR+77hapJMD7HZdTQGdx9I3PgmJ X-Received: by 2002:a05:6a20:8fa5:b0:19c:9b48:6982 with SMTP id k37-20020a056a208fa500b0019c9b486982mr296790pzj.46.1707189966735; Mon, 05 Feb 2024 19:26:06 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUUpP4a1dvLNnp4PIyWXb8YzcC8C7liV6E8lGOx66DxbyKcVVPnNiMihI+PK5G3zy1qXsHDgG6/ArXcxWIXxqICYhpSasJXxiArNHfGFWmHHyI8wrXuepUCMqfMyOiqyQtzwai1pfJUlVof7ZyzBX9S3zx59hqEmaILLynyM7gGatFUBbdpisNZ/erR9MRNwnkBYiJfBwBb52HmRlhC56GIBdeZI5qEmFNzaWB6uW1adCJW3nVywmB4ErjJObvjj6E3EQ+qacZ1dqhcgx9VbgDTyD9/ff2sHTEH+V/TlvjtVijHu3i9AwL+kJQUZSI1QyIWgcesO8qWsM8oX9d0rXaCF6VFKyzCg5L9vVuel98RSC+sySGJsLoYeu+3gVXh6qGAiIg0mc+/8Cp/72hdnMe/rTY+sj78lUSWQXMV5dlwRZUmt6Z8JFc3wn9KShuSx7iSFNaBDeDH6Aqj83nkaePS4dNIBxw5vXpL1RLZtLy9XRilFFkhQKAoKVeOHpfrx4t+dLeyrlp4GHmqSRuLtDP0lGjyMOlLJbJpeSGUtJYPvnmR4HbwqoFpmSWPuUSITL5gxepdigFOFTEMn/oTfOwk8qJpfZBkgU6z/YFjznf1uFRPFeQV+fwh/xBV9QZUs14TsXvNslgpZ54biUhllHteBlFbUf46phPtdQd/PXXnnxvqXSLnj4ZZlnXl7NTHHm5sfhYrdeifEd04TMr29vmX5Zid+QVw7lAcA7qpgB+fNZSKCgZD3CM2fkC2HiD4gPUWz2jJGakQBQfOhCwQZ7ESEveYhbt2x8A/y+hGTW8qSQ+Neap2xlc= Received: from ?IPV6:2600:1700:e321:62f0:329c:23ff:fee3:9d7c? ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id b18-20020a170902d51200b001d986ce6893sm636562plg.198.2024.02.05.19.26.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Feb 2024 19:26:06 -0800 (PST) Sender: Guenter Roeck Message-ID: Date: Mon, 5 Feb 2024 19:26:04 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/1] hwmon: Add driver for Astera Labs PT5161L retimer Content-Language: en-US To: Cosmo Chou Cc: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jdelvare@suse.com, corbet@lwn.net, broonie@kernel.org, naresh.solanki@9elements.com, vincent@vtremblay.dev, patrick.rudolph@9elements.com, luca.ceresoli@bootlin.com, bhelgaas@google.com, festevam@denx.de, alexander.stein@ew.tq-group.com, heiko@sntech.de, jernej.skrabec@gmail.com, macromorgan@hotmail.com, forbidden405@foxmail.com, sre@kernel.org, linus.walleij@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, cosmo.chou@quantatw.com References: <20240205152013.3833940-1-chou.cosmo@gmail.com> <20240205152013.3833940-2-chou.cosmo@gmail.com> <4a504043-e24d-4119-8c5d-107f0d371110@roeck-us.net> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/W8Vk BIsJMaWOhks//7d92Uf3EArDlDShwR2+D+AMon8NULuLBHiEUQARAQABzTJHdWVudGVyIFJv ZWNrIChMaW51eCBhY2NvdW50KSA8bGludXhAcm9lY2stdXMubmV0PsLBgQQTAQIAKwIbAwYL CQgHAwIGFQgCCQoLBBYCAwECHgECF4ACGQEFAlV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XlNFUPUYMrIKi9joBhu18ssf5i5Q= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/5/24 19:05, Cosmo Chou wrote: > On Tue, Feb 06, 2024 at 3:43 AM +0800, Guenter Roeck wrote: >> >> On Mon, Feb 05, 2024 at 11:20:13PM +0800, Cosmo Chou wrote: >>> This driver implements support for temperature monitoring of Astera Labs >>> PT5161L series PCIe retimer chips. >>> >>> This driver implementation originates from the CSDK available at >>> Link: https://github.com/facebook/openbmc/tree/helium/common/recipes-lib/retimer-v2.14 >>> The communication protocol utilized is based on the I2C/SMBus standard. >>> >>> Signed-off-by: Cosmo Chou >>> --- >> [ ... ] >> >>> +static ssize_t pt5161l_debugfs_read_fw_ver(struct file *file, char __user *buf, >>> + size_t count, loff_t *ppos) >>> +{ >>> + struct pt5161l_data *data = file->private_data; >>> + int ret; >>> + char ver[32]; >>> + >>> + mutex_lock(&data->lock); >>> + ret = pt5161l_fwsts_check(data); >>> + mutex_unlock(&data->lock); >>> + if (ret) >>> + return ret; >>> + >>> + ret = snprintf(ver, sizeof(ver), "%u.%u.%u\n", data->fw_ver.major, >>> + data->fw_ver.minor, data->fw_ver.build); >>> + if (ret < 0) >>> + return ret; >>> + >> >> You almost got me here ;-). snprintf() never returns a negative error code, >> so checking for it is not necessary. >> > Oh! You're right. > >>> + return simple_read_from_buffer(buf, count, ppos, ver, ret + 1); >> >> Number of bytes written plus 1 ? Why ? > It's just to include the string terminator '\0'. > If that was needed, it would be risky. snprintf() truncates the output if the buffer is not large enough. You might want to consider using scnprintf() instead. But then I am not sure if that is needed in the first place. Almost all code I checked doesn't do that, and it seems to be likely that the few drivers who do that are simply wrong. Can you explain why the string terminator needs to be added to the output ? Thanks, Guenter