Re: [PATCH 1/8] LinuxPPS core support.

From: Greg KH
Date: Sat Feb 09 2008 - 01:41:42 EST


On Fri, Feb 08, 2008 at 07:00:37PM +0100, Rodolfo Giometti wrote:
> This patch adds the kernel side of the PPS support currently named
> "LinuxPPS".
>
> PPS means "pulse per second" and a PPS source is just a device which
> provides a high precision signal each second so that an application
> can use it to adjust system clock time.
>
> Common use is the combination of the NTPD as userland program with a
> GPS receiver as PPS source to obtain a wallclock-time with
> sub-millisecond synchronisation to UTC.
>
> To obtain this goal the userland programs shoud use the PPS API
> specification (RFC 2783 - Pulse-Per-Second API for UNIX-like Operating
> Systems, Version 1.0) which in part is implemented by this patch. It
> provides a set of chars devices, one per PPS source, which can be used
> to get the time signal. The RFC's functions can be implemented by
> accessing to these char devices.
>
> Signed-off-by: Rodolfo Giometti <giometti@xxxxxxxx>
> ---
> MAINTAINERS | 7 +
> drivers/Kconfig | 2 +
> drivers/Makefile | 1 +
> drivers/pps/Kconfig | 32 +++++
> drivers/pps/Makefile | 10 ++
> drivers/pps/kapi.c | 272 +++++++++++++++++++++++++++++++++++++++
> drivers/pps/pps.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++
> drivers/pps/sysfs.c | 142 +++++++++++++++++++++

As you are adding sysfs files, please also describe them in
Documentation/ABI/ in this same series of patches.

> +void pps_sysfs_remove_source_entry(struct pps_device *pps)
> +{
> + /* Delete info files */
> + if (pps->info.mode & PPS_CAPTUREASSERT)
> + device_remove_file(pps->dev, &dev_attr_assert);
> +
> + if (pps->info.mode & PPS_CAPTURECLEAR)
> + device_remove_file(pps->dev, &dev_attr_clear);
> +
> + device_remove_file(pps->dev, &dev_attr_mode);
> + device_remove_file(pps->dev, &dev_attr_echo);
> + device_remove_file(pps->dev, &dev_attr_name);
> + device_remove_file(pps->dev, &dev_attr_path);
> +}
> +
> +int pps_sysfs_create_source_entry(struct pps_device *pps)
> +{
> + int ret;
> +
> + /* Create file "assert" and "clear" according to source capability */
> + if (pps->info.mode & PPS_CAPTUREASSERT) {
> + ret = device_create_file(pps->dev, &dev_attr_assert);
> + if (ret)
> + dev_err(pps->dev, "unable to create \"assert\" "
> + "sysfs entry");
> + }
> +
> + if (pps->info.mode & PPS_CAPTURECLEAR) {
> + ret = device_create_file(pps->dev, &dev_attr_clear);
> + if (ret)
> + dev_err(pps->dev, "unable to create \"clear\" "
> + "sysfs entry");
> + }
> +
> + ret = device_create_file(pps->dev, &dev_attr_mode);
> + if (ret)
> + dev_err(pps->dev, "unable to create \"mode\" sysfs entry");
> + ret = device_create_file(pps->dev, &dev_attr_echo);
> + if (ret)
> + dev_err(pps->dev, "unable to create \"echo\" sysfs entry");
> + ret = device_create_file(pps->dev, &dev_attr_name);
> + if (ret)
> + dev_err(pps->dev, "unable to create \"name\" sysfs entry");
> + ret = device_create_file(pps->dev, &dev_attr_path);
> + if (ret)
> + dev_err(pps->dev, "unable to create \"path\" sysfs entry");

Why not use a default attribute group?

That way the files are created before the uevent is issued, and the
amount of code you have to write is much smaller.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/