From: Jakub Kicinski <kuba@kernel.org>
To: Divya Koppera <divya.koppera@microchip.com>
Cc: <andrew@lunn.ch>, <arun.ramadoss@microchip.com>,
<UNGLinuxDriver@microchip.com>, <hkallweit1@gmail.com>,
<linux@armlinux.org.uk>, <davem@davemloft.net>,
<edumazet@google.com>, <pabeni@redhat.com>,
<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<richardcochran@gmail.com>, <vadim.fedorenko@linux.dev>
Subject: Re: [PATCH net-next v2 3/3] net: phy: microchip_rds_ptp : Add PEROUT feature library for RDS PTP supported phys
Date: Mon, 13 Jan 2025 19:20:02 -0800 [thread overview]
Message-ID: <20250113192002.39dda2c2@kernel.org> (raw)
In-Reply-To: <20250109102533.15621-4-divya.koppera@microchip.com>
On Thu, 9 Jan 2025 15:55:33 +0530 Divya Koppera wrote:
> + switch (ts_on_nsec) {
> + case 200000000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_200MS_;
> + break;
> + case 100000000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_100MS_;
> + break;
> + case 50000000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_50MS_;
> + break;
> + case 10000000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_10MS_;
> + break;
> + case 5000000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_5MS_;
> + break;
> + case 1000000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_1MS_;
> + break;
> + case 500000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_500US_;
> + break;
> + case 100000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_100US_;
> + break;
> + case 50000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_50US_;
> + break;
> + case 10000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_10US_;
> + break;
> + case 5000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_5US_;
> + break;
> + case 1000:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_1US_;
> + break;
> + case 500:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_500NS_;
> + break;
> + case 100:
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_100NS_;
> + break;
> + default:
> + phydev_warn(phydev, "Using default pulse width of 200ms\n");
> + *pulse_width = MCHP_RDS_PTP_GEN_CFG_LTC_EVT_200MS_;
> + break;
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_200MS_ 13
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_100MS_ 12
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_50MS_ 11
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_10MS_ 10
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_5MS_ 9
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_1MS_ 8
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_500US_ 7
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_100US_ 6
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_50US_ 5
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_10US_ 4
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_5US_ 3
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_1US_ 2
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_500NS_ 1
+#define MCHP_RDS_PTP_GEN_CFG_LTC_EVT_100NS_ 0
1) seems a bit weird to me that you go to 200ms whenever user asks for
a value that couldn't be provided exactly. Why not go to the next
good value?
2) this is not very well coded up, given that the values you're
translating to are a just natural numbers you can use a table
static const sup_on_necs[] = {
100, /* 100ns */
500, /* 500ns */
1000, /* 1us */
5000, /* 5us */
...
};
for (i = 0; i < ARRAY_SIZE(sup_on_necs); i++) {
if (ts_on_nsec <= sup_on_necs[i]) {
*pulse_width = i;
break;
}
}
--
pw-bot: cr
prev parent reply other threads:[~2025-01-14 3:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 10:25 [PATCH net-next v2 0/3] Add PEROUT library for RDS PTP supported phys Divya Koppera
2025-01-09 10:25 ` [PATCH net-next v2 1/3] net: phy: microchip_rds_ptp: Header file library changes for PEROUT Divya Koppera
2025-01-09 10:25 ` [PATCH net-next v2 2/3] net: phy: microchip_t1: Enable pin out specific to lan887x phy for PEROUT signal Divya Koppera
2025-01-09 10:25 ` [PATCH net-next v2 3/3] net: phy: microchip_rds_ptp : Add PEROUT feature library for RDS PTP supported phys Divya Koppera
2025-01-14 3:20 ` Jakub Kicinski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250113192002.39dda2c2@kernel.org \
--to=kuba@kernel.org \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=arun.ramadoss@microchip.com \
--cc=davem@davemloft.net \
--cc=divya.koppera@microchip.com \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.