public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dominik Brodowski <linux@brodo.de>
To: rmk@arm.linux.org.uk
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2.5] pcmcia: fill device directory in sysfs with files
Date: Sat, 29 Mar 2003 18:43:28 +0100	[thread overview]
Message-ID: <20030329174328.GA25268@brodo.de> (raw)

This patch adds three files (manf_id, card_id, func_id) for any pcmcia
device registered with the sysfs core.

sysfs_output-1
 ds.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+)

diff -ruN linux-original/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
--- linux-original/drivers/pcmcia/ds.c	2003-03-29 18:00:43.000000000 +0100
+++ linux/drivers/pcmcia/ds.c	2003-03-29 18:34:10.000000000 +0100
@@ -267,6 +267,20 @@
 
 /*====================================================================*/
 
+#define show_one(file_name, object, test)	 			\
+static ssize_t show_##file_name 					\
+(struct device *dev, char *buf)						\
+{									\
+	struct pcmcia_device *p_dev = to_pcmcia_dev(dev);		\
+	return p_dev->test ? sprintf (buf, "%x\n", p_dev->object) : 	\
+			sprintf(buf, "unknown\n");			\
+}	 								\
+DEVICE_ATTR(file_name, 0444, show_##file_name, NULL);
+
+show_one(func_id, funcid.func, has_funcid);
+show_one(manf_id, manfid.manf, has_manfid);
+show_one(card_id, manfid.card, has_manfid);
+
 static int pcmcia_add_card(struct pcmcia_bus_socket *s)
 {
 	struct pcmcia_device *p_dev;
@@ -368,6 +382,11 @@
 	}
 	list_add(&p_dev->socket_device_list, &s->devices_list);
 
+	/* add sysfs files */
+	device_create_file(&p_dev->dev, &dev_attr_func_id);
+	device_create_file(&p_dev->dev, &dev_attr_manf_id);
+	device_create_file(&p_dev->dev, &dev_attr_card_id);
+
 	/* if we got a multifunction device, we need to register more devices,
 	 * so go back up */
 	func++;
@@ -387,6 +406,11 @@
 	down(&s->devices_list_sem);
 	list_for_each_safe(p1, p2, &s->devices_list) {
 		struct pcmcia_device *p_dev = container_of(p1, struct pcmcia_device, socket_device_list);
+
+		device_remove_file(&p_dev->dev, &dev_attr_func_id);
+		device_remove_file(&p_dev->dev, &dev_attr_manf_id);
+		device_remove_file(&p_dev->dev, &dev_attr_card_id);
+
 		device_unregister(&p_dev->dev);
 		list_del(&p_dev->socket_device_list);
 		kfree(p_dev);

                 reply	other threads:[~2003-03-29 17:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030329174328.GA25268@brodo.de \
    --to=linux@brodo.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    /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