Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp388745rdb; Fri, 5 Jan 2024 13:27:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEvxHI9fLKaAx6q+Icb8KTIM46xBqJMGW62WbOAiLfc+rF0utFqF9UybXpj2Bak5JjZyecP X-Received: by 2002:a17:90a:8d13:b0:28c:2871:95fd with SMTP id c19-20020a17090a8d1300b0028c287195fdmr89571pjo.14.1704490039136; Fri, 05 Jan 2024 13:27:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704490039; cv=none; d=google.com; s=arc-20160816; b=c7daM2eFUMshIPVumem8esIoylXYdC/aZatqlogGdB9kQeeNmbpXdFD1f2QsL+iRY/ beLm1CpfNzK/04JJy7aU5KDkXQl7DMUSNu4CVUrs8pnKOF8NKm66lGwqvgrMZDgoGiyt qhb/nk+kt3mhjnys2Mi71G5MJvPqLm4lSSu7ACoZ7mh/yLb91emtfXKjeHOYXyDKyje1 a74AfFOgDaZh9SNdM6A2d9UPD4pJLqf1S9Aa2ueMliaN9egkwWn+FjIFyjQ+4GhnccLo 5xLhPYV94OVH0rIz4a80j7k9BkhX5pl92ZvVjmnvaQOMM4rt6bbOgR0Os/dphurTfQsw gzOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=PqSlYJPHFsfDSILfzlsJNktpR9JJe/Dd8UB/IVPyoyo=; fh=ZN/Xum6mwRGCddSqtL2ZsIMT2rwovbu6gtybYSIQFlU=; b=fMeMYeFd7zWYzewpPlVy9O96/afXVN6jRbpdRbfVFIQ194epYkaxmORpFcbdsvAUOE +DB8JE6RygTHQpdqpl/667gjQR0RaxWMASx5R0SCaBmAEmxgpQQHFCJxfJ4bclqP2ZEw kKqDKxHwGZiJHk3raK4w+q9P54BM3ggIRhv67qNgqPu0/ZP7yhacJ2JzfVaJgSoCRwCz ROdyvfuJyu6fx+BJkC48wWDoguNEsZg6M5p2hKte4N8qKdzjvh2v9yEROvhaOJa888WI kDs9r6hpxUIGjNZWr3NeUDrfraZNw0+IUVv7S0r1IZMHIG7uucSNVAnhQlEQSH0EIe0H AKXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T+B23zuI; spf=pass (google.com: domain of linux-kernel+bounces-18366-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18366-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id o3-20020a17090aac0300b0028bbce449fcsi1410599pjq.86.2024.01.05.13.27.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 13:27:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18366-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T+B23zuI; spf=pass (google.com: domain of linux-kernel+bounces-18366-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18366-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 B29352858E4 for ; Fri, 5 Jan 2024 21:27:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60A1A27473; Fri, 5 Jan 2024 21:27:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T+B23zuI" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8FEED225CF; Fri, 5 Jan 2024 21:27:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94668C433C7; Fri, 5 Jan 2024 21:27:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704490029; bh=MSvK0YSrVz1QlpLijrS22XUNQU4szhEzReI8uN+n+0Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T+B23zuI3xK/gY/o0sxfFa5ya/2Cspmo9ntle+URDTEnEQzSI1YoaR5ljGMKLvlVy HgFmR/m/7oKMgffSnYSExmWqcNF6+YVena8OHwzFQD7hw2rfp2jhCYKdkH97urS0Bu yyXxo1dOxE7cq27F9kb7KA5fCgsCUOxm9T5QTO0nAXnEeBf/zbJ3Wdu+ND4HHVOGW+ dYDpgOVG/nAp+ZgBh45W/8/Z2AkPpl5U0O56SuMZdNMR0qFGbY53iPSZJ8aps0pVm2 tksIXIMeVzux/YZIYmlKePiC/phj0zftAmKrTjEf9dYkQ4WNzSa3VAOn7msSYgFX2A M2G5bWuIENhIA== Date: Fri, 5 Jan 2024 21:27:04 +0000 From: Simon Horman To: Min Li Cc: richardcochran@gmail.com, lee@kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Min Li Subject: Re: [PATCH net-next v7 2/2] ptp: add FemtoClock3 Wireless as ptp hardware clock Message-ID: <20240105212704.GB31813@kernel.org> References: <20240105152313.24235-1-lnimi@hotmail.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=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jan 05, 2024 at 10:23:13AM -0500, Min Li wrote: > From: Min Li > > The RENESAS FemtoClock3 Wireless is a high-performance jitter attenuator, > frequency translator, and clock synthesizer. The device is comprised of 3 > digital PLLs (DPLL) to track CLKIN inputs and three independent low phase > noise fractional output dividers (FOD) that output low phase noise clocks. > > FemtoClock3 supports one Time Synchronization (Time Sync) channel to enable > an external processor to control the phase and frequency of the Time Sync > channel and to take phase measurements using the TDC. Intended applications > are synchronization using the precision time protocol (PTP) and > synchronization with 0.5 Hz and 1 Hz signals from GNSS. > > Signed-off-by: Min Li Hi Min Li, some minor suggestions from my side. ... > +static int idtfc3_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) > +{ > + struct idtfc3 *idtfc3 = container_of(ptp, struct idtfc3, caps); > + int err; > + > + mutex_lock(idtfc3->lock); > + err = _idtfc3_gettime(idtfc3, ts); > + mutex_unlock(idtfc3->lock); > + > + if (err) > + dev_err(idtfc3->dev, "Failed at line %d in %s!", > + __LINE__, __func__); IMHO messages like the one above offer no value to users. I would remove it and similar messages. > + > + return err; > +} > + > +static int _idtfc3_settime(struct idtfc3 *idtfc3, const struct timespec64 *ts) > +{ > + s64 offset_ns, now_ns, sync_ns; > + u32 counter, sub_ns; > + int now; > + > + if (timespec64_valid(ts) == false) { > + dev_err(idtfc3->dev, "%s: invalid timespec", __func__); > + return -EINVAL; > + } > + > + now = idtfc3_read_subcounter(idtfc3); > + if (now < 0) > + return now; > + > + offset_ns = (idtfc3->sub_sync_count - now) * idtfc3->ns_per_counter; > + now_ns = timespec64_to_ns(ts); > + sync_ns = ns2counters(idtfc3, offset_ns + now_ns, &sub_ns); nit: sync_ns is set but unused in this function. I think you can remove sync_ns from this function and simply do: ns2counters(idtfc3, offset_ns + now_ns, &sub_ns); > + > + counter = sub_ns / idtfc3->ns_per_counter; > + return idtfc3_timecounter_update(idtfc3, counter, now_ns); > +} ...