public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre Ossman <drzeus-list@drzeus.cx>
To: Andrew Morton <akpm@osdl.org>
Cc: Russell King <rmk+lkml@arm.linux.org.uk>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] mmc: conditional scr sysfs entry
Date: Tue, 30 Aug 2005 11:35:03 +0200	[thread overview]
Message-ID: <43142847.3020703@drzeus.cx> (raw)

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

Only show the scr file in sysfs for SD cards. Previously this was
present for all cards but had a contents of 0 for MMC cards.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>

[-- Attachment #2: mmc-conditional-scr.patch --]
[-- Type: text/x-patch, Size: 1300 bytes --]

Index: linux-wbsd/drivers/mmc/mmc_sysfs.c
===================================================================
--- linux-wbsd/drivers/mmc/mmc_sysfs.c	(revision 157)
+++ linux-wbsd/drivers/mmc/mmc_sysfs.c	(working copy)
@@ -46,7 +46,6 @@
 static struct device_attribute mmc_dev_attrs[] = {
 	MMC_ATTR_RO(cid),
 	MMC_ATTR_RO(csd),
-	MMC_ATTR_RO(scr),
 	MMC_ATTR_RO(date),
 	MMC_ATTR_RO(fwrev),
 	MMC_ATTR_RO(hwrev),
@@ -57,6 +56,8 @@
 	__ATTR_NULL
 };
 
+static struct device_attribute mmc_dev_attr_scr = MMC_ATTR_RO(scr);
+
 
 static void mmc_release_card(struct device *dev)
 {
@@ -207,10 +208,20 @@
  */
 int mmc_register_card(struct mmc_card *card)
 {
+	int ret;
+
 	snprintf(card->dev.bus_id, sizeof(card->dev.bus_id),
 		 "%s:%04x", card->host->host_name, card->rca);
 
-	return device_add(&card->dev);
+	ret = device_add(&card->dev);
+	if (ret == 0) {
+		if (mmc_card_sd(card)) {
+			ret = device_create_file(&card->dev, &mmc_dev_attr_scr);
+			if (ret)
+				device_del(&card->dev);
+		}
+	}
+	return ret;
 }
 
 /*
@@ -219,8 +230,12 @@
  */
 void mmc_remove_card(struct mmc_card *card)
 {
-	if (mmc_card_present(card))
+	if (mmc_card_present(card)) {
+		if (mmc_card_sd(card))
+			device_remove_file(&card->dev, &mmc_dev_attr_scr);
+
 		device_del(&card->dev);
+	}
 
 	put_device(&card->dev);
 }

                 reply	other threads:[~2005-08-30  9:35 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=43142847.3020703@drzeus.cx \
    --to=drzeus-list@drzeus.cx \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk+lkml@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