* [PATCH v1 0/7] ptp: ocp: A fix and refactoring
@ 2025-11-11 16:52 Andy Shevchenko
2025-11-11 16:52 ` [PATCH net-next v1 1/7] ptp: ocp: Refactor signal_show() and fix %ptT misuse Andy Shevchenko
` (7 more replies)
0 siblings, 8 replies; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
Here is the fix for incorrect use of %ptT with the associated
refactoring and additional cleanups.
Note, %ptS, which is introduced in another series, doesn't fit
here, that's why this fix is separated from that series.
Andy Shevchenko (7):
ptp: ocp: Refactor signal_show() and fix %ptT misuse
ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware
ptp: ocp: Refactor ptp_ocp_i2c_notifier_call()
ptp: ocp: Apply standard pattern for cleaning up loop
ptp: ocp: Reuse META's PCI vendor ID
ptp: ocp: Sort headers alphabetically
ptp: ocp: don't use "proxy" headers
drivers/ptp/ptp_ocp.c | 128 +++++++++++++++++++++++-------------------
1 file changed, 70 insertions(+), 58 deletions(-)
--
2.50.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH net-next v1 1/7] ptp: ocp: Refactor signal_show() and fix %ptT misuse
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
@ 2025-11-11 16:52 ` Andy Shevchenko
2025-11-12 13:29 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 2/7] ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware Andy Shevchenko
` (6 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
Refactor signal_show() to avoid sequential calls to sysfs_emit*()
and use the same pattern to get the index of a signal as it's done
in signal_store().
While at it, fix wrong use of %ptT against struct timespec64.
It's kinda lucky that it worked just because the first member
there 64-bit and it's of time64_t type. Now with %ptS it may
be used correctly.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ptp/ptp_ocp.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index eeebe4d149f7..95889f85ffb2 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -3250,20 +3250,16 @@ signal_show(struct device *dev, struct device_attribute *attr, char *buf)
struct dev_ext_attribute *ea = to_ext_attr(attr);
struct ptp_ocp *bp = dev_get_drvdata(dev);
struct ptp_ocp_signal *signal;
+ int gen = (uintptr_t)ea->var;
struct timespec64 ts;
- ssize_t count;
- int i;
- i = (uintptr_t)ea->var;
- signal = &bp->signal[i];
-
- count = sysfs_emit(buf, "%llu %d %llu %d", signal->period,
- signal->duty, signal->phase, signal->polarity);
+ signal = &bp->signal[gen];
ts = ktime_to_timespec64(signal->start);
- count += sysfs_emit_at(buf, count, " %ptT TAI\n", &ts);
- return count;
+ return sysfs_emit(buf, "%llu %d %llu %d %ptT TAI\n",
+ signal->period, signal->duty, signal->phase, signal->polarity,
+ &ts.tv_sec);
}
static EXT_ATTR_RW(signal, signal, 0);
static EXT_ATTR_RW(signal, signal, 1);
--
2.50.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next v1 2/7] ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
2025-11-11 16:52 ` [PATCH net-next v1 1/7] ptp: ocp: Refactor signal_show() and fix %ptT misuse Andy Shevchenko
@ 2025-11-11 16:52 ` Andy Shevchenko
2025-11-12 13:38 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 3/7] ptp: ocp: Refactor ptp_ocp_i2c_notifier_call() Andy Shevchenko
` (5 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
It's a common practice to make resource release functions be NULL-aware.
Make ptp_ocp_unregister_ext() NULL-aware.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ptp/ptp_ocp.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 95889f85ffb2..28243fb1d78f 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -2225,6 +2225,9 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
static void
ptp_ocp_unregister_ext(struct ptp_ocp_ext_src *ext)
{
+ if (!ext)
+ return;
+
ext->info->enable(ext, ~0, false);
pci_free_irq(ext->bp->pdev, ext->irq_vec, ext);
kfree(ext);
@@ -4558,21 +4561,14 @@ ptp_ocp_detach(struct ptp_ocp *bp)
ptp_ocp_detach_sysfs(bp);
ptp_ocp_attr_group_del(bp);
timer_delete_sync(&bp->watchdog);
- if (bp->ts0)
- ptp_ocp_unregister_ext(bp->ts0);
- if (bp->ts1)
- ptp_ocp_unregister_ext(bp->ts1);
- if (bp->ts2)
- ptp_ocp_unregister_ext(bp->ts2);
- if (bp->ts3)
- ptp_ocp_unregister_ext(bp->ts3);
- if (bp->ts4)
- ptp_ocp_unregister_ext(bp->ts4);
- if (bp->pps)
- ptp_ocp_unregister_ext(bp->pps);
+ ptp_ocp_unregister_ext(bp->ts0);
+ ptp_ocp_unregister_ext(bp->ts1);
+ ptp_ocp_unregister_ext(bp->ts2);
+ ptp_ocp_unregister_ext(bp->ts3);
+ ptp_ocp_unregister_ext(bp->ts4);
+ ptp_ocp_unregister_ext(bp->pps);
for (i = 0; i < 4; i++)
- if (bp->signal_out[i])
- ptp_ocp_unregister_ext(bp->signal_out[i]);
+ ptp_ocp_unregister_ext(bp->signal_out[i]);
for (i = 0; i < __PORT_COUNT; i++)
if (bp->port[i].line != -1)
serial8250_unregister_port(bp->port[i].line);
--
2.50.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next v1 3/7] ptp: ocp: Refactor ptp_ocp_i2c_notifier_call()
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
2025-11-11 16:52 ` [PATCH net-next v1 1/7] ptp: ocp: Refactor signal_show() and fix %ptT misuse Andy Shevchenko
2025-11-11 16:52 ` [PATCH net-next v1 2/7] ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware Andy Shevchenko
@ 2025-11-11 16:52 ` Andy Shevchenko
2025-11-12 13:45 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop Andy Shevchenko
` (4 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
Refactor ptp_ocp_i2c_notifier_call() to avoid unneeded local variable.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ptp/ptp_ocp.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 28243fb1d78f..1dbbca4197bc 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -4872,16 +4872,6 @@ ptp_ocp_i2c_notifier_call(struct notifier_block *nb,
{
struct device *dev, *child = data;
struct ptp_ocp *bp;
- bool add;
-
- switch (action) {
- case BUS_NOTIFY_ADD_DEVICE:
- case BUS_NOTIFY_DEL_DEVICE:
- add = action == BUS_NOTIFY_ADD_DEVICE;
- break;
- default:
- return 0;
- }
if (!i2c_verify_adapter(child))
return 0;
@@ -4894,10 +4884,17 @@ ptp_ocp_i2c_notifier_call(struct notifier_block *nb,
found:
bp = dev_get_drvdata(dev);
- if (add)
+
+ switch (action) {
+ case BUS_NOTIFY_ADD_DEVICE:
ptp_ocp_symlink(bp, child, "i2c");
- else
+ break;
+ case BUS_NOTIFY_DEL_DEVICE:
sysfs_remove_link(&bp->dev.kobj, "i2c");
+ break;
+ default:
+ return 0;
+ }
return 0;
}
--
2.50.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
` (2 preceding siblings ...)
2025-11-11 16:52 ` [PATCH net-next v1 3/7] ptp: ocp: Refactor ptp_ocp_i2c_notifier_call() Andy Shevchenko
@ 2025-11-11 16:52 ` Andy Shevchenko
2025-11-12 13:36 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 5/7] ptp: ocp: Reuse META's PCI vendor ID Andy Shevchenko
` (3 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
The while (i--) is a standard pattern for the cleaning up loops.
Apply this pattern where it makes sense in the driver.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ptp/ptp_ocp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 1dbbca4197bc..67a4c60cbbcd 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -4821,8 +4821,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return 0;
out_dpll:
- while (i) {
- --i;
+ while (i--) {
dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp->sma[i]);
dpll_pin_put(bp->sma[i].dpll_pin);
}
--
2.50.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next v1 5/7] ptp: ocp: Reuse META's PCI vendor ID
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
` (3 preceding siblings ...)
2025-11-11 16:52 ` [PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop Andy Shevchenko
@ 2025-11-11 16:52 ` Andy Shevchenko
2025-11-12 13:37 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 6/7] ptp: ocp: Sort headers alphabetically Andy Shevchenko
` (2 subsequent siblings)
7 siblings, 1 reply; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
The META's PCI vendor ID is listed already in the pci_ids.h.
Reuse it here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ptp/ptp_ocp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 67a4c60cbbcd..4c4b4a40e9d4 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -25,8 +25,7 @@
#include <linux/crc16.h>
#include <linux/dpll.h>
-#define PCI_VENDOR_ID_FACEBOOK 0x1d9b
-#define PCI_DEVICE_ID_FACEBOOK_TIMECARD 0x0400
+#define PCI_DEVICE_ID_META_TIMECARD 0x0400
#define PCI_VENDOR_ID_CELESTICA 0x18d4
#define PCI_DEVICE_ID_CELESTICA_TIMECARD 0x1008
@@ -1030,7 +1029,7 @@ static struct ocp_resource ocp_adva_resource[] = {
};
static const struct pci_device_id ptp_ocp_pcidev_id[] = {
- { PCI_DEVICE_DATA(FACEBOOK, TIMECARD, &ocp_fb_resource) },
+ { PCI_DEVICE_DATA(META, TIMECARD, &ocp_fb_resource) },
{ PCI_DEVICE_DATA(CELESTICA, TIMECARD, &ocp_fb_resource) },
{ PCI_DEVICE_DATA(OROLIA, ARTCARD, &ocp_art_resource) },
{ PCI_DEVICE_DATA(ADVA, TIMECARD, &ocp_adva_resource) },
--
2.50.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next v1 6/7] ptp: ocp: Sort headers alphabetically
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
` (4 preceding siblings ...)
2025-11-11 16:52 ` [PATCH net-next v1 5/7] ptp: ocp: Reuse META's PCI vendor ID Andy Shevchenko
@ 2025-11-11 16:52 ` Andy Shevchenko
2025-11-11 16:52 ` [PATCH net-next v1 7/7] ptp: ocp: don't use "proxy" headers Andy Shevchenko
2025-11-12 15:27 ` [PATCH v1 0/7] ptp: ocp: A fix and refactoring Vadim Fedorenko
7 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
For better maintenance sort headers alphabetically.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ptp/ptp_ocp.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 4c4b4a40e9d4..984293a2a696 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -2,28 +2,28 @@
/* Copyright (c) 2020 Facebook */
#include <linux/bits.h>
+#include <linux/clk-provider.h>
+#include <linux/clkdev.h>
+#include <linux/crc16.h>
+#include <linux/debugfs.h>
+#include <linux/dpll.h>
#include <linux/err.h>
+#include <linux/i2c.h>
+#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
-#include <linux/debugfs.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/serial_8250.h>
-#include <linux/clkdev.h>
-#include <linux/clk-provider.h>
-#include <linux/platform_device.h>
-#include <linux/platform_data/i2c-xiic.h>
-#include <linux/platform_data/i2c-ocores.h>
-#include <linux/ptp_clock_kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/spi/xilinx_spi.h>
-#include <linux/spi/altera.h>
-#include <net/devlink.h>
-#include <linux/i2c.h>
#include <linux/mtd/mtd.h>
#include <linux/nvmem-consumer.h>
-#include <linux/crc16.h>
-#include <linux/dpll.h>
+#include <linux/pci.h>
+#include <linux/platform_data/i2c-ocores.h>
+#include <linux/platform_data/i2c-xiic.h>
+#include <linux/platform_device.h>
+#include <linux/ptp_clock_kernel.h>
+#include <linux/serial_8250.h>
+#include <linux/spi/altera.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/xilinx_spi.h>
+#include <net/devlink.h>
#define PCI_DEVICE_ID_META_TIMECARD 0x0400
--
2.50.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net-next v1 7/7] ptp: ocp: don't use "proxy" headers
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
` (5 preceding siblings ...)
2025-11-11 16:52 ` [PATCH net-next v1 6/7] ptp: ocp: Sort headers alphabetically Andy Shevchenko
@ 2025-11-11 16:52 ` Andy Shevchenko
2025-11-12 15:27 ` [PATCH v1 0/7] ptp: ocp: A fix and refactoring Vadim Fedorenko
7 siblings, 0 replies; 14+ messages in thread
From: Andy Shevchenko @ 2025-11-11 16:52 UTC (permalink / raw)
To: netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Vadim Fedorenko, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Andy Shevchenko
Update header inclusions to follow IWYU (Include What You Use) principle.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/ptp/ptp_ocp.c | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 984293a2a696..4b18f1e5ae9a 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -1,28 +1,53 @@
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2020 Facebook */
-#include <linux/bits.h>
+#include <linux/array_size.h>
+#include <linux/bitops.h>
#include <linux/clk-provider.h>
#include <linux/clkdev.h>
+#include <linux/container_of.h>
#include <linux/crc16.h>
#include <linux/debugfs.h>
+#include <linux/device.h>
#include <linux/dpll.h>
#include <linux/err.h>
#include <linux/i2c.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
+#include <linux/idr.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/ioport.h>
+#include <linux/kstrtox.h>
+#include <linux/limits.h>
+#include <linux/math64.h>
+#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/mtd/mtd.h>
+#include <linux/mutex.h>
#include <linux/nvmem-consumer.h>
#include <linux/pci.h>
#include <linux/platform_data/i2c-ocores.h>
#include <linux/platform_data/i2c-xiic.h>
#include <linux/platform_device.h>
#include <linux/ptp_clock_kernel.h>
+#include <linux/seq_file.h>
#include <linux/serial_8250.h>
+#include <linux/slab.h>
#include <linux/spi/altera.h>
#include <linux/spi/spi.h>
#include <linux/spi/xilinx_spi.h>
+#include <linux/spinlock.h>
+#include <linux/sprintf.h>
+#include <linux/stddef.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/time.h>
+#include <linux/timekeeping.h>
+#include <linux/timer.h>
+#include <linux/types.h>
+#include <linux/workqueue.h>
+
+#include <asm/byteorder.h>
+
#include <net/devlink.h>
#define PCI_DEVICE_ID_META_TIMECARD 0x0400
--
2.50.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH net-next v1 1/7] ptp: ocp: Refactor signal_show() and fix %ptT misuse
2025-11-11 16:52 ` [PATCH net-next v1 1/7] ptp: ocp: Refactor signal_show() and fix %ptT misuse Andy Shevchenko
@ 2025-11-12 13:29 ` Vadim Fedorenko
0 siblings, 0 replies; 14+ messages in thread
From: Vadim Fedorenko @ 2025-11-12 13:29 UTC (permalink / raw)
To: Andy Shevchenko, netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On 11/11/2025 16:52, Andy Shevchenko wrote:
> Refactor signal_show() to avoid sequential calls to sysfs_emit*()
> and use the same pattern to get the index of a signal as it's done
> in signal_store().
>
> While at it, fix wrong use of %ptT against struct timespec64.
> It's kinda lucky that it worked just because the first member
> there 64-bit and it's of time64_t type. Now with %ptS it may
> be used correctly.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/ptp/ptp_ocp.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index eeebe4d149f7..95889f85ffb2 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -3250,20 +3250,16 @@ signal_show(struct device *dev, struct device_attribute *attr, char *buf)
> struct dev_ext_attribute *ea = to_ext_attr(attr);
> struct ptp_ocp *bp = dev_get_drvdata(dev);
> struct ptp_ocp_signal *signal;
> + int gen = (uintptr_t)ea->var;
> struct timespec64 ts;
> - ssize_t count;
> - int i;
>
> - i = (uintptr_t)ea->var;
> - signal = &bp->signal[i];
> -
> - count = sysfs_emit(buf, "%llu %d %llu %d", signal->period,
> - signal->duty, signal->phase, signal->polarity);
> + signal = &bp->signal[gen];
>
> ts = ktime_to_timespec64(signal->start);
> - count += sysfs_emit_at(buf, count, " %ptT TAI\n", &ts);
>
> - return count;
> + return sysfs_emit(buf, "%llu %d %llu %d %ptT TAI\n",
> + signal->period, signal->duty, signal->phase, signal->polarity,
> + &ts.tv_sec);
> }
> static EXT_ATTR_RW(signal, signal, 0);
> static EXT_ATTR_RW(signal, signal, 1);
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop
2025-11-11 16:52 ` [PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop Andy Shevchenko
@ 2025-11-12 13:36 ` Vadim Fedorenko
0 siblings, 0 replies; 14+ messages in thread
From: Vadim Fedorenko @ 2025-11-12 13:36 UTC (permalink / raw)
To: Andy Shevchenko, netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On 11/11/2025 16:52, Andy Shevchenko wrote:
> The while (i--) is a standard pattern for the cleaning up loops.
> Apply this pattern where it makes sense in the driver.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/ptp/ptp_ocp.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 1dbbca4197bc..67a4c60cbbcd 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -4821,8 +4821,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>
> return 0;
> out_dpll:
> - while (i) {
> - --i;
> + while (i--) {
> dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp->sma[i]);
> dpll_pin_put(bp->sma[i].dpll_pin);
> }
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next v1 5/7] ptp: ocp: Reuse META's PCI vendor ID
2025-11-11 16:52 ` [PATCH net-next v1 5/7] ptp: ocp: Reuse META's PCI vendor ID Andy Shevchenko
@ 2025-11-12 13:37 ` Vadim Fedorenko
0 siblings, 0 replies; 14+ messages in thread
From: Vadim Fedorenko @ 2025-11-12 13:37 UTC (permalink / raw)
To: Andy Shevchenko, netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On 11/11/2025 16:52, Andy Shevchenko wrote:
> The META's PCI vendor ID is listed already in the pci_ids.h.
> Reuse it here.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/ptp/ptp_ocp.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 67a4c60cbbcd..4c4b4a40e9d4 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -25,8 +25,7 @@
> #include <linux/crc16.h>
> #include <linux/dpll.h>
>
> -#define PCI_VENDOR_ID_FACEBOOK 0x1d9b
> -#define PCI_DEVICE_ID_FACEBOOK_TIMECARD 0x0400
> +#define PCI_DEVICE_ID_META_TIMECARD 0x0400
>
> #define PCI_VENDOR_ID_CELESTICA 0x18d4
> #define PCI_DEVICE_ID_CELESTICA_TIMECARD 0x1008
> @@ -1030,7 +1029,7 @@ static struct ocp_resource ocp_adva_resource[] = {
> };
>
> static const struct pci_device_id ptp_ocp_pcidev_id[] = {
> - { PCI_DEVICE_DATA(FACEBOOK, TIMECARD, &ocp_fb_resource) },
> + { PCI_DEVICE_DATA(META, TIMECARD, &ocp_fb_resource) },
> { PCI_DEVICE_DATA(CELESTICA, TIMECARD, &ocp_fb_resource) },
> { PCI_DEVICE_DATA(OROLIA, ARTCARD, &ocp_art_resource) },
> { PCI_DEVICE_DATA(ADVA, TIMECARD, &ocp_adva_resource) },
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next v1 2/7] ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware
2025-11-11 16:52 ` [PATCH net-next v1 2/7] ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware Andy Shevchenko
@ 2025-11-12 13:38 ` Vadim Fedorenko
0 siblings, 0 replies; 14+ messages in thread
From: Vadim Fedorenko @ 2025-11-12 13:38 UTC (permalink / raw)
To: Andy Shevchenko, netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On 11/11/2025 16:52, Andy Shevchenko wrote:
> It's a common practice to make resource release functions be NULL-aware.
> Make ptp_ocp_unregister_ext() NULL-aware.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/ptp/ptp_ocp.c | 24 ++++++++++--------------
> 1 file changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 95889f85ffb2..28243fb1d78f 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -2225,6 +2225,9 @@ ptp_ocp_ts_enable(void *priv, u32 req, bool enable)
> static void
> ptp_ocp_unregister_ext(struct ptp_ocp_ext_src *ext)
> {
> + if (!ext)
> + return;
> +
> ext->info->enable(ext, ~0, false);
> pci_free_irq(ext->bp->pdev, ext->irq_vec, ext);
> kfree(ext);
> @@ -4558,21 +4561,14 @@ ptp_ocp_detach(struct ptp_ocp *bp)
> ptp_ocp_detach_sysfs(bp);
> ptp_ocp_attr_group_del(bp);
> timer_delete_sync(&bp->watchdog);
> - if (bp->ts0)
> - ptp_ocp_unregister_ext(bp->ts0);
> - if (bp->ts1)
> - ptp_ocp_unregister_ext(bp->ts1);
> - if (bp->ts2)
> - ptp_ocp_unregister_ext(bp->ts2);
> - if (bp->ts3)
> - ptp_ocp_unregister_ext(bp->ts3);
> - if (bp->ts4)
> - ptp_ocp_unregister_ext(bp->ts4);
> - if (bp->pps)
> - ptp_ocp_unregister_ext(bp->pps);
> + ptp_ocp_unregister_ext(bp->ts0);
> + ptp_ocp_unregister_ext(bp->ts1);
> + ptp_ocp_unregister_ext(bp->ts2);
> + ptp_ocp_unregister_ext(bp->ts3);
> + ptp_ocp_unregister_ext(bp->ts4);
> + ptp_ocp_unregister_ext(bp->pps);
> for (i = 0; i < 4; i++)
> - if (bp->signal_out[i])
> - ptp_ocp_unregister_ext(bp->signal_out[i]);
> + ptp_ocp_unregister_ext(bp->signal_out[i]);
> for (i = 0; i < __PORT_COUNT; i++)
> if (bp->port[i].line != -1)
> serial8250_unregister_port(bp->port[i].line);
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net-next v1 3/7] ptp: ocp: Refactor ptp_ocp_i2c_notifier_call()
2025-11-11 16:52 ` [PATCH net-next v1 3/7] ptp: ocp: Refactor ptp_ocp_i2c_notifier_call() Andy Shevchenko
@ 2025-11-12 13:45 ` Vadim Fedorenko
0 siblings, 0 replies; 14+ messages in thread
From: Vadim Fedorenko @ 2025-11-12 13:45 UTC (permalink / raw)
To: Andy Shevchenko, netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On 11/11/2025 16:52, Andy Shevchenko wrote:
> Refactor ptp_ocp_i2c_notifier_call() to avoid unneeded local variable.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/ptp/ptp_ocp.c | 21 +++++++++------------
> 1 file changed, 9 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 28243fb1d78f..1dbbca4197bc 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -4872,16 +4872,6 @@ ptp_ocp_i2c_notifier_call(struct notifier_block *nb,
> {
> struct device *dev, *child = data;
> struct ptp_ocp *bp;
> - bool add;
> -
> - switch (action) {
> - case BUS_NOTIFY_ADD_DEVICE:
> - case BUS_NOTIFY_DEL_DEVICE:
> - add = action == BUS_NOTIFY_ADD_DEVICE;
> - break;
> - default:
> - return 0;
> - }
the reason we've done it is to avoid iterating over devices and do
string comparisons for actions we don't care about. We can still avoid
local variable by changing if condition later in the code, but I'm not
sure this refactor gives any benefits.
>
> if (!i2c_verify_adapter(child))
> return 0;
> @@ -4894,10 +4884,17 @@ ptp_ocp_i2c_notifier_call(struct notifier_block *nb,
>
> found:
> bp = dev_get_drvdata(dev);
> - if (add)
> +
> + switch (action) {
> + case BUS_NOTIFY_ADD_DEVICE:
> ptp_ocp_symlink(bp, child, "i2c");
> - else
> + break;
> + case BUS_NOTIFY_DEL_DEVICE:
> sysfs_remove_link(&bp->dev.kobj, "i2c");
> + break;
> + default:
> + return 0;
> + }
>
> return 0;
> }
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v1 0/7] ptp: ocp: A fix and refactoring
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
` (6 preceding siblings ...)
2025-11-11 16:52 ` [PATCH net-next v1 7/7] ptp: ocp: don't use "proxy" headers Andy Shevchenko
@ 2025-11-12 15:27 ` Vadim Fedorenko
7 siblings, 0 replies; 14+ messages in thread
From: Vadim Fedorenko @ 2025-11-12 15:27 UTC (permalink / raw)
To: Andy Shevchenko, netdev, linux-kernel
Cc: Richard Cochran, Jonathan Lemon, Andrew Lunn, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
On 11/11/2025 16:52, Andy Shevchenko wrote:
> ptp: ocp: Sort headers alphabetically
> ptp: ocp: don't use "proxy" headers
I don't see benefits of these 2 patches, what's the reason?
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-11-12 15:27 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 16:52 [PATCH v1 0/7] ptp: ocp: A fix and refactoring Andy Shevchenko
2025-11-11 16:52 ` [PATCH net-next v1 1/7] ptp: ocp: Refactor signal_show() and fix %ptT misuse Andy Shevchenko
2025-11-12 13:29 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 2/7] ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware Andy Shevchenko
2025-11-12 13:38 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 3/7] ptp: ocp: Refactor ptp_ocp_i2c_notifier_call() Andy Shevchenko
2025-11-12 13:45 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 4/7] ptp: ocp: Apply standard pattern for cleaning up loop Andy Shevchenko
2025-11-12 13:36 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 5/7] ptp: ocp: Reuse META's PCI vendor ID Andy Shevchenko
2025-11-12 13:37 ` Vadim Fedorenko
2025-11-11 16:52 ` [PATCH net-next v1 6/7] ptp: ocp: Sort headers alphabetically Andy Shevchenko
2025-11-11 16:52 ` [PATCH net-next v1 7/7] ptp: ocp: don't use "proxy" headers Andy Shevchenko
2025-11-12 15:27 ` [PATCH v1 0/7] ptp: ocp: A fix and refactoring Vadim Fedorenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).