From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: linux1394-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 7/8] firewire: core: clarify generate_config_rom usage
Date: Thu, 8 Oct 2009 00:42:27 +0200 (CEST) [thread overview]
Message-ID: <tkrat.666fc82e31e3111e@s5r6.in-berlin.de> (raw)
In-Reply-To: <tkrat.27888275592fd267@s5r6.in-berlin.de>
Move the static config ROM buffer into the scope of the two callers of
generate_config_rom(). That way the ROM length can be passed over as
return value rather than through a pointer argument.
It also becomes more obvious that accesses to the config ROM buffer have
to be serialized and how this is accomplished. And firewire-core.ko
shrinks a bit as well.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
drivers/firewire/core-card.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
Index: linux-2.6.31/drivers/firewire/core-card.c
===================================================================
--- linux-2.6.31.orig/drivers/firewire/core-card.c
+++ linux-2.6.31/drivers/firewire/core-card.c
@@ -69,6 +69,8 @@ static LIST_HEAD(card_list);
static LIST_HEAD(descriptor_list);
static int descriptor_count;
+static __be32 tmp_config_rom[256];
+
#define BIB_CRC(v) ((v) << 0)
#define BIB_CRC_LENGTH(v) ((v) << 16)
#define BIB_INFO_LENGTH(v) ((v) << 24)
@@ -84,10 +86,9 @@ static int descriptor_count;
#define BIB_CMC ((1) << 30)
#define BIB_IMC ((1) << 31)
-static __be32 *generate_config_rom(struct fw_card *card, size_t *rom_length)
+static size_t generate_config_rom(struct fw_card *card, __be32 *config_rom)
{
struct fw_descriptor *desc;
- static __be32 config_rom[256];
int i, j, k, length;
/*
@@ -142,20 +143,17 @@ static __be32 *generate_config_rom(struc
for (i = 0; i < j; i += length + 1)
length = __compute_block_crc(config_rom + i);
- *rom_length = j;
-
- return config_rom;
+ return j;
}
static void update_config_roms(void)
{
struct fw_card *card;
- __be32 *config_rom;
size_t length;
list_for_each_entry (card, &card_list, link) {
- config_rom = generate_config_rom(card, &length);
- card->driver->set_config_rom(card, config_rom, length);
+ length = generate_config_rom(card, tmp_config_rom);
+ card->driver->set_config_rom(card, tmp_config_rom, length);
}
}
@@ -443,7 +441,6 @@ EXPORT_SYMBOL(fw_card_initialize);
int fw_card_add(struct fw_card *card,
u32 max_receive, u32 link_speed, u64 guid)
{
- __be32 *config_rom;
size_t length;
int ret;
@@ -453,8 +450,8 @@ int fw_card_add(struct fw_card *card,
mutex_lock(&card_mutex);
- config_rom = generate_config_rom(card, &length);
- ret = card->driver->enable(card, config_rom, length);
+ length = generate_config_rom(card, tmp_config_rom);
+ ret = card->driver->enable(card, tmp_config_rom, length);
if (ret == 0)
list_add_tail(&card->link, &card_list);
--
Stefan Richter
-=====-==--= =-=- -=---
http://arcgraph.de/sr/
next prev parent reply other threads:[~2009-10-07 22:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 22:38 [PATCH 0/8] firewire: misc updates Stefan Richter
2009-10-07 22:39 ` [PATCH 1/8] firewire: sbp2: provide fallback if mgt_ORB_timeout is missing Stefan Richter
2009-10-07 22:39 ` [PATCH 2/8] firewire: cdev: fix memory leak in an error path Stefan Richter
2009-10-07 22:40 ` [PATCH 3/8] firewire: cdev: reduce stack usage by ioctl_dispatch Stefan Richter
2009-10-14 20:43 ` Stefan Richter
2009-10-14 21:14 ` [PATCH update] " Stefan Richter
[not found] ` <4AD6F672.705@cam.ac.uk>
2009-10-15 19:16 ` [PATCH v3] " Stefan Richter
2009-10-07 22:41 ` [PATCH 4/8] firewire: normalize style of queue_work wrappers Stefan Richter
2009-10-07 22:41 ` [PATCH 5/8] firewire: cdev: normalize variable names Stefan Richter
2009-10-07 22:41 ` [PATCH 6/8] firewire: optimize config ROM creation Stefan Richter
2009-10-07 22:42 ` Stefan Richter [this message]
2009-10-07 22:42 ` [PATCH 8/8] firewire: core: optimize Topology Map creation Stefan Richter
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=tkrat.666fc82e31e3111e@s5r6.in-berlin.de \
--to=stefanr@s5r6.in-berlin.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®