LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: oakad@exemail.com.au
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, Alex Dubov <oakad@yahoo.com>
Subject: [PATCH 06/11] tifm: fix memorystick host initialization code
Date: Wed,  5 Mar 2008 03:02:23 +1100	[thread overview]
Message-ID: <1204646548-27466-7-git-send-email-oakad@exemail.com.au> (raw)
In-Reply-To: <1204646548-27466-6-git-send-email-oakad@exemail.com.au>

From: Alex Dubov <oakad@yahoo.com>

Instead of assuming that host is powered on only once at card insertion,
allow for the possibility that memstick layer may need to cycle card's
power to get it out from some unhealthy states.

Signed-off-by: Alex Dubov <oakad@yahoo.com>
---
 drivers/memstick/host/tifm_ms.c |   40 ++++++++++++++------------------------
 1 files changed, 15 insertions(+), 25 deletions(-)

diff --git a/drivers/memstick/host/tifm_ms.c b/drivers/memstick/host/tifm_ms.c
index b88f5b3..2b5bf52 100644
--- a/drivers/memstick/host/tifm_ms.c
+++ b/drivers/memstick/host/tifm_ms.c
@@ -496,7 +496,18 @@ static void tifm_ms_set_param(struct memstick_host *msh,
 
 	switch (param) {
 	case MEMSTICK_POWER:
-		/* this is set by card detection mechanism */
+		/* also affected by media detection mechanism */
+		if (value == MEMSTICK_POWER_ON) {
+			host->mode_mask = TIFM_MS_SYS_SRAC | TIFM_MS_SYS_REI;
+			writel(TIFM_MS_SYS_RESET, sock->addr + SOCK_MS_SYSTEM);
+			writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
+			       sock->addr + SOCK_MS_SYSTEM);
+			writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
+		} else if (value == MEMSTICK_POWER_OFF) {
+			writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
+			       sock->addr + SOCK_MS_SYSTEM);
+			writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
+		}
 		break;
 	case MEMSTICK_INTERFACE:
 		if (value == MEMSTICK_SERIAL) {
@@ -531,22 +542,6 @@ static void tifm_ms_abort(unsigned long data)
 	tifm_eject(host->dev);
 }
 
-static int tifm_ms_initialize_host(struct tifm_ms *host)
-{
-	struct tifm_dev *sock = host->dev;
-	struct memstick_host *msh = tifm_get_drvdata(sock);
-
-	host->mode_mask = TIFM_MS_SYS_SRAC | TIFM_MS_SYS_REI;
-	writel(TIFM_MS_SYS_RESET, sock->addr + SOCK_MS_SYSTEM);
-	writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
-	       sock->addr + SOCK_MS_SYSTEM);
-	writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
-	if (tifm_has_ms_pif(sock))
-		msh->caps |= MEMSTICK_CAP_PAR4;
-
-	return 0;
-}
-
 static int tifm_ms_probe(struct tifm_dev *sock)
 {
 	struct memstick_host *msh;
@@ -575,10 +570,10 @@ static int tifm_ms_probe(struct tifm_dev *sock)
 	msh->set_param = tifm_ms_set_param;
 	sock->card_event = tifm_ms_card_event;
 	sock->data_event = tifm_ms_data_event;
-	rc = tifm_ms_initialize_host(host);
+	if (tifm_has_ms_pif(sock))
+		msh->caps |= MEMSTICK_CAP_PAR4;
 
-	if (!rc)
-		rc = memstick_add_host(msh);
+	rc = memstick_add_host(msh);
 	if (!rc)
 		return 0;
 
@@ -616,11 +611,6 @@ static void tifm_ms_remove(struct tifm_dev *sock)
 	spin_unlock_irqrestore(&sock->lock, flags);
 
 	memstick_remove_host(msh);
-
-	writel(TIFM_MS_SYS_FCLR | TIFM_MS_SYS_INTCLR,
-	       sock->addr + SOCK_MS_SYSTEM);
-	writel(0xffffffff, sock->addr + SOCK_MS_STATUS);
-
 	memstick_free_host(msh);
 }
 
-- 
1.5.3.6


  reply	other threads:[~2008-03-04 16:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-04 16:02 MemoryStick driver updates oakad
2008-03-04 16:02 ` [PATCH 01/11] memstick: introduce correct definitions in the header oakad
2008-03-04 16:02   ` [PATCH 02/11] memstick: add memstick_suspend/resume_host methods oakad
2008-03-04 16:02     ` [PATCH 03/11] memstick: make sure number of command retries is exactly as specified oakad
2008-03-04 16:02       ` [PATCH 04/11] memstick: drop DRIVER_VERSION numbers as meaningless oakad
2008-03-04 16:02         ` [PATCH 05/11] tifm: fix the MemoryStick host fifo handling code oakad
2008-03-04 16:02           ` oakad [this message]
2008-03-04 16:02             ` [PATCH 07/11] tifm: clear interrupt mask bits before setting them on adapter init oakad
2008-03-04 16:02               ` [PATCH 08/11] memstick: add support for decoding "specfile" media attributes oakad
2008-03-04 16:02                 ` [PATCH 09/11] memstick: fix parsing of "assembly_date" attribute field oakad
2008-03-04 16:02                   ` [PATCH 10/11] memstick: try harder to recover from unsuccessful interface mode switch oakad
2008-03-04 16:02                     ` [PATCH 11/11] memstick: add support for JMicron jmb38x MemoryStick host controller oakad
2008-03-05 23:17                       ` Andrew Morton
2008-03-05 22:59           ` [PATCH 05/11] tifm: fix the MemoryStick host fifo handling code Andrew Morton
2008-03-05 23:21 ` MemoryStick driver updates Andrew Morton

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=1204646548-27466-7-git-send-email-oakad@exemail.com.au \
    --to=oakad@exemail.com.au \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oakad@yahoo.com \
    /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).