[PATCH 5/5] card insert / eject
Dominik Brodowski
linux at dominikbrodowski.de
Tue May 11 22:28:50 BST 2004
Add two further attributes, "card_insert" and "card_eject". Reading these
files will fail; but writing _anything_ non-empty to these files will execute
an user insert/ejection request -- equivalent to "cardctl insert",
"cardctl eject".
drivers/pcmcia/socket_sysfs.c | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+)
diff -ruN linux-original/drivers/pcmcia/socket_sysfs.c linux/drivers/pcmcia/socket_sysfs.c
--- linux-original/drivers/pcmcia/socket_sysfs.c 2004-05-11 19:32:47.985582376 +0200
+++ linux/drivers/pcmcia/socket_sysfs.c 2004-05-11 19:41:19.975748040 +0200
@@ -92,11 +92,47 @@
}
static CLASS_DEVICE_ATTR(card_vcc, 0400, pccard_show_vcc, NULL);
+
+static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count)
+{
+ ssize_t ret;
+ struct pcmcia_socket *s = to_socket(dev);
+
+ if (s->state & SOCKET_PRESENT)
+ return -EINVAL;
+ if (!count)
+ return -EINVAL;
+
+ ret = pcmcia_insert_card(s);
+
+ return ret ? ret : count;
+}
+static CLASS_DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert);
+
+static ssize_t pccard_store_eject(struct class_device *dev, const char *buf, size_t count)
+{
+ ssize_t ret;
+ struct pcmcia_socket *s = to_socket(dev);
+
+ if (!(s->state & SOCKET_PRESENT))
+ return -ENODEV;
+ if (!count)
+ return -EINVAL;
+
+ ret = pcmcia_eject_card(s);
+
+ return ret ? ret : count;
+}
+static CLASS_DEVICE_ATTR(card_eject, 0200, NULL, pccard_store_eject);
+
+
static struct class_device_attribute *pccard_socket_attributes[] = {
&class_device_attr_card_type,
&class_device_attr_card_voltage,
&class_device_attr_card_vpp,
&class_device_attr_card_vcc,
+ &class_device_attr_card_insert,
+ &class_device_attr_card_eject,
NULL,
};
More information about the linux-pcmcia
mailing list