All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rodolfo Giometti <giometti@enneenne.com>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Dave Jones <davej@redhat.com>
Subject: Re: [PATCH 1/8] LinuxPPS core support.
Date: Mon, 11 Feb 2008 19:42:57 +0100	[thread overview]
Message-ID: <20080211184257.GA16773@enneenne.com> (raw)
In-Reply-To: <20080211183153.GA19771@enneenne.com>

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

      reply	other threads:[~2008-02-11 18:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08 18:00 LinuxPPS: the PPS Linux implementation Rodolfo Giometti
2008-02-08 18:00 ` [PATCH 1/8] LinuxPPS core support Rodolfo Giometti
2008-02-08 18:00   ` [PATCH 2/8] PPS: basic documentation file Rodolfo Giometti
2008-02-08 18:00     ` [PATCH 3/8] PPS: userland header file for PPS API Rodolfo Giometti
2008-02-08 18:00       ` [PATCH 4/8] PPS: documentation programs and examples Rodolfo Giometti
2008-02-08 18:00         ` [PATCH 5/8] PPS: LinuxPPS clients support Rodolfo Giometti
2008-02-08 18:00           ` [PATCH 6/8] PPS: serial " Rodolfo Giometti
2008-02-08 18:00             ` [PATCH 7/8] PPS: example program to enable PPS support on serial ports Rodolfo Giometti
2008-02-08 18:00               ` [PATCH 8/8] PPS: parallel port clients support Rodolfo Giometti
2008-02-08 19:11   ` [PATCH 1/8] LinuxPPS core support Sam Ravnborg
2008-02-09  6:45   ` Greg KH
2008-02-11  9:53     ` Rodolfo Giometti
2008-02-11 15:25       ` Greg KH
2008-02-11 18:31         ` Rodolfo Giometti
2008-02-11 18:42           ` Rodolfo Giometti [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=20080211184257.GA16773@enneenne.com \
    --to=giometti@enneenne.com \
    --cc=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.