Thread (15 messages) flat view 15 messages, 3 authors, 2012-09-24

Re: [PATCH net-next 3/3] ptp: derive the device name from the parent device

From: Ben Hutchings <hidden>
Date: 2012-09-21 17:19:31

On Fri, 2012-09-21 at 19:00 +0200, Richard Cochran wrote:
PTP Hardware Clock device have a name that appears under sysfs that should
identify the underlying device. Instead of leaving it up to the driver to
invent a name, this patch changes the registration to automatically use
the name from the parent device.
I thought you wanted the driver name and not the parent device name?

[...]
quoted hunk ↗ jump to hunk
diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c
index 6e47450..60fa259 100644
--- a/drivers/ptp/ptp_clock.c
+++ b/drivers/ptp/ptp_clock.c
[...]
quoted hunk ↗ jump to hunk
@@ -219,11 +220,13 @@ struct ptp_clock *ptp_clock_register(struct ptp_clock_info *info)
        init_waitqueue_head(&ptp->tsev_wq);
 
        /* Create a new device in our class. */
-       ptp->dev = device_create(ptp_class, NULL, ptp->devid, ptp,
+       ptp->dev = device_create(ptp_class, parent, ptp->devid, ptp,
                                 "ptp%d", ptp->index);
        if (IS_ERR(ptp->dev))
                goto no_device;
 
+       ptp->name = parent ? dev_name(parent) : dev_name(ptp->dev);
+
The fallback of using dev_name(ptp->dev) is a bit sad, as that's the
same name userland already has when it reads this attribute.

[...]
quoted hunk ↗ jump to hunk
diff --git a/drivers/ptp/ptp_ixp46x.c b/drivers/ptp/ptp_ixp46x.c
index e03c406..c0939b1 100644
--- a/drivers/ptp/ptp_ixp46x.c
+++ b/drivers/ptp/ptp_ixp46x.c
@@ -241,7 +241,6 @@ static int ptp_ixp_enable(struct ptp_clock_info *ptp,
 
 static struct ptp_clock_info ptp_ixp_caps = {
 	.owner		= THIS_MODULE,
-	.name		= "IXP46X timer",
 	.max_adj	= 66666655,
 	.n_ext_ts	= N_EXT_TS,
 	.pps		= 0,
@@ -298,7 +297,7 @@ static int __init ptp_ixp_init(void)
 
 	ixp_clock.caps = ptp_ixp_caps;
 
-	ixp_clock.ptp_clock = ptp_clock_register(&ixp_clock.caps);
+	ixp_clock.ptp_clock = ptp_clock_register(&ixp_clock.caps, NULL);
[...]

I think this should really register a platform driver and a platform
device to be the parent of the clock device.  And then you don't need
the fallback for parent == NULL.

Since David has pulled the addition of PTP/PHC support to sfc, that will
need to be adjusted as well.

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help