From: Karl Hiramoto <karl@hiramoto.org>
To: linux-atm-general@lists.sourceforge.net, netdev@vger.kernel.org,
chas@cmf.nrl.navy.mil, davem@davemloft.net
Cc: Karl Hiramoto <karl@hiramoto.org>
Subject: [PATCH v5 3/9] atm/adummy: add syfs DEVICE_ATTR to change signal
Date: Fri, 9 Jul 2010 08:55:32 +0200 [thread overview]
Message-ID: <1278658538-6769-4-git-send-email-karl@hiramoto.org> (raw)
In-Reply-To: <1278658538-6769-1-git-send-email-karl@hiramoto.org>
Signed-off-by: Karl Hiramoto <karl@hiramoto.org>
---
drivers/atm/adummy.c | 39 +++++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index 6d44f07..46b9476 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -40,6 +40,42 @@ struct adummy_dev {
static LIST_HEAD(adummy_devs);
+static ssize_t __set_signal(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ struct atm_dev *atm_dev = container_of(dev, struct atm_dev, class_dev);
+ int signal;
+
+ if (sscanf(buf, "%d", &signal) == 1) {
+
+ if (signal < ATM_PHY_SIG_LOST || signal > ATM_PHY_SIG_FOUND)
+ signal = ATM_PHY_SIG_UNKNOWN;
+
+ atm_dev_signal_change(atm_dev, signal);
+ return 1;
+ }
+ return -EINVAL;
+}
+
+static ssize_t __show_signal(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct atm_dev *atm_dev = container_of(dev, struct atm_dev, class_dev);
+ return sprintf(buf, "%d\n", atm_dev->signal);
+}
+static DEVICE_ATTR(signal, 0644, __show_signal, __set_signal);
+
+static struct attribute *adummy_attrs[] = {
+ &dev_attr_signal.attr,
+ NULL
+};
+
+static struct attribute_group adummy_group_attrs = {
+ .name = NULL, /* We want them in dev's root folder */
+ .attrs = adummy_attrs
+};
+
static int __init
adummy_start(struct atm_dev *dev)
{
@@ -128,6 +164,9 @@ static int __init adummy_init(void)
adummy_dev->atm_dev = atm_dev;
atm_dev->dev_data = adummy_dev;
+ if (sysfs_create_group(&atm_dev->class_dev.kobj, &adummy_group_attrs))
+ dev_err(&atm_dev->class_dev, "Could not register attrs for adummy\n");
+
if (adummy_start(atm_dev)) {
printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n");
err = -ENODEV;
--
1.7.1
next prev parent reply other threads:[~2010-07-09 6:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-09 6:55 [PATCH v5 0/9] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice Karl Hiramoto
2010-07-09 6:55 ` [PATCH v5 1/9] atm: propagate signal changes via notifier Karl Hiramoto
2010-07-09 6:55 ` [PATCH v5 2/9] atm/br2684: register notifier event for carrier signal changes Karl Hiramoto
2010-07-09 6:55 ` Karl Hiramoto [this message]
2010-07-09 6:55 ` [PATCH v5 4/9] atm/idt77105.c: call atm_dev_signal_change() when " Karl Hiramoto
2010-07-09 6:55 ` [PATCH v5 5/9] atm/solos-pci: " Karl Hiramoto
2010-07-09 6:55 ` [PATCH v5 6/9] atm/suni.c: " Karl Hiramoto
2010-07-09 6:55 ` [PATCH v5 7/9] usb/atm/cxacru.c: " Karl Hiramoto
2010-07-09 6:55 ` [PATCH v5 8/9] usb/atm/speedtch.c: " Karl Hiramoto
2010-07-09 6:55 ` [PATCH v5 9/9] usb/atm/ueagle-atm.c: " Karl Hiramoto
2010-07-09 7:10 ` [PATCH v5 0/9] atm: propagate atm_dev signal carrier to LOWER_UP of netdevice David Miller
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=1278658538-6769-4-git-send-email-karl@hiramoto.org \
--to=karl@hiramoto.org \
--cc=chas@cmf.nrl.navy.mil \
--cc=davem@davemloft.net \
--cc=linux-atm-general@lists.sourceforge.net \
--cc=netdev@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 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).