Messages in this thread | | | Date | Mon, 11 Feb 2008 19:42:57 +0100 | From | Rodolfo Giometti <> | Subject | Re: [PATCH 1/8] LinuxPPS core support. |
| |
On Mon, Feb 11, 2008 at 07:31:53PM +0100, Rodolfo Giometti wrote: > Do you think is better create these files anyway and in case report a > NULL string?
Is that ok?
/* * Attribute functions */
static ssize_t pps_show_assert(struct device *dev, struct device_attribute *attr, char *buf) { struct pps_device *pps = dev_get_drvdata(dev);
if (!(pps->info.mode & PPS_CAPTUREASSERT)) return 0;
return sprintf(buf, "%lld.%09d#%d\n", pps->assert_tu.sec, pps->assert_tu.nsec, pps->assert_sequence); } DEVICE_ATTR(assert, S_IRUGO, pps_show_assert, NULL);
static ssize_t pps_show_clear(struct device *dev, struct device_attribute *attr, char *buf) { struct pps_device *pps = dev_get_drvdata(dev);
if (!(pps->info.mode & PPS_CAPTURECLEAR)) return 0;
return sprintf(buf, "%lld.%09d#%d\n", pps->clear_tu.sec, pps->clear_tu.nsec, pps->clear_sequence); } DEVICE_ATTR(clear, S_IRUGO, pps_show_clear, NULL);
static ssize_t pps_show_mode(struct device *dev, struct device_attribute *attr, char *buf) { struct pps_device *pps = dev_get_drvdata(dev);
return sprintf(buf, "%4x\n", pps->info.mode); } DEVICE_ATTR(mode, S_IRUGO, pps_show_mode, NULL);
...
static struct attribute *pps_attrs[] = { &dev_attr_mode.attr, &dev_attr_echo.attr, &dev_attr_name.attr, &dev_attr_path.attr, &dev_attr_assert.attr, &dev_attr_clear.attr, NULL };
static struct attribute_group pps_group = { .attrs = pps_attrs, };
/* * Public functions */
void pps_sysfs_remove_source_entry(struct pps_device *pps) { /* Delete info files */ sysfs_remove_group(&pps->dev->kobj, &pps_group); }
int pps_sysfs_create_source_entry(struct pps_device *pps) { int ret;
/* Create info files */ ret = sysfs_create_group(&pps->dev->kobj, &pps_group); if (ret) dev_err(pps->dev, "unable to create default sysfs entries");
return 0; }
Ciao,
Rodolfo
--
GNU/Linux Solutions e-mail: giometti@enneenne.com Linux Device Driver giometti@gnudd.com Embedded Systems giometti@linux.it UNIX programming phone: +39 349 2432127
| |