mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Paul Fertser <fercerpav@gmail.com>
To: barebox@lists.infradead.org
Subject: [RFC][PATCH 1/3] spi: let master a chance to setup device before registering it
Date: Mon, 29 Aug 2011 16:25:42 +0400	[thread overview]
Message-ID: <3c2cf8578f00f7200d39dc396856cb8a63e48d4d.1314683390.git.fercerpav@gmail.com> (raw)

Call setup() before registering the device because registering leads
to a probe routine of the slave device and that requires an
initialised master.

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
---

TBH, i do not fully understand the framework, so this and the following patches
might be rather wrong. But the issues i tried to fix were real indeed :)

 drivers/spi/spi.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index b561f9d..82393ea 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -80,7 +80,6 @@ struct spi_device *spi_new_device(struct spi_master *master,
 	strcpy(proxy->dev.name, chip->name);
 	proxy->dev.type_data = proxy;
 	dev_add_child(master->dev, &proxy->dev);
-	status = register_device(&proxy->dev);
 
 	/* drivers may modify this initial i/o setup */
 	status = master->setup(proxy);
@@ -90,10 +89,10 @@ struct spi_device *spi_new_device(struct spi_master *master,
 		goto fail;
 	}
 
-	return proxy;
+	register_device(&proxy->dev);
 
+	return proxy;
 fail:
-	unregister_device(&proxy->dev);
 	free(proxy);
 	return NULL;
 }
-- 
1.5.2.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2011-08-30  5:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-29 12:25 Paul Fertser [this message]
2011-08-29 12:39 ` [RFC][PATCH 2/3] spi: enfore default bits_per_word value Paul Fertser
2011-08-30  5:39 ` [RFC][PATCH 3/3] spi: indicate in the docs that per-transfer bpw setting is not supported Paul Fertser

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=3c2cf8578f00f7200d39dc396856cb8a63e48d4d.1314683390.git.fercerpav@gmail.com \
    --to=fercerpav@gmail.com \
    --cc=barebox@lists.infradead.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