Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
35a85a5e
Commit
35a85a5e
authored
Mar 24, 2003
by
Randy Dunlap
Committed by
Greg Kroah-Hartman
Mar 24, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] USB: usb/misc/emi26.c stack reduction
Reduces stack usage in emi26_load_firmware().
parent
d67fc77a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
drivers/usb/misc/emi26.c
drivers/usb/misc/emi26.c
+25
-12
No files found.
drivers/usb/misc/emi26.c
View file @
35a85a5e
...
@@ -78,19 +78,28 @@ static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit)
...
@@ -78,19 +78,28 @@ static int emi26_set_reset (struct usb_device *dev, unsigned char reset_bit)
return
response
;
return
response
;
}
}
#define FW_LOAD_SIZE 1023
static
int
emi26_load_firmware
(
struct
usb_device
*
dev
)
static
int
emi26_load_firmware
(
struct
usb_device
*
dev
)
{
{
int
err
;
int
err
;
int
i
;
int
i
;
int
pos
=
0
;
/* Position in hex record */
int
pos
=
0
;
/* Position in hex record */
__u32
addr
;
/* Address to write */
__u32
addr
;
/* Address to write */
__u8
buf
[
1023
];
__u8
*
buf
;
buf
=
kmalloc
(
FW_LOAD_SIZE
,
GFP_KERNEL
);
if
(
!
buf
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
-
ENOMEM
);
err
=
-
ENOMEM
;
goto
wraperr
;
}
/* Assert reset (stop the CPU in the EMI) */
/* Assert reset (stop the CPU in the EMI) */
err
=
emi26_set_reset
(
dev
,
1
);
err
=
emi26_set_reset
(
dev
,
1
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
/* 1. We need to put the loader for the FPGA into the EZ-USB */
/* 1. We need to put the loader for the FPGA into the EZ-USB */
...
@@ -98,7 +107,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -98,7 +107,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_writememory
(
dev
,
g_Loader
[
i
].
address
,
g_Loader
[
i
].
data
,
g_Loader
[
i
].
length
,
ANCHOR_LOAD_INTERNAL
);
err
=
emi26_writememory
(
dev
,
g_Loader
[
i
].
address
,
g_Loader
[
i
].
data
,
g_Loader
[
i
].
length
,
ANCHOR_LOAD_INTERNAL
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
}
}
...
@@ -113,7 +122,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -113,7 +122,7 @@ static int emi26_load_firmware (struct usb_device *dev)
addr
=
g_bitstream
[
pos
].
address
;
addr
=
g_bitstream
[
pos
].
address
;
/* intel hex records are terminated with type 0 element */
/* intel hex records are terminated with type 0 element */
while
((
g_bitstream
[
pos
].
type
==
0
)
&&
(
i
+
g_bitstream
[
pos
].
length
<
sizeof
(
buf
)
))
{
while
((
g_bitstream
[
pos
].
type
==
0
)
&&
(
i
+
g_bitstream
[
pos
].
length
<
FW_LOAD_SIZE
))
{
memcpy
(
buf
+
i
,
g_bitstream
[
pos
].
data
,
g_bitstream
[
pos
].
length
);
memcpy
(
buf
+
i
,
g_bitstream
[
pos
].
data
,
g_bitstream
[
pos
].
length
);
i
+=
g_bitstream
[
pos
].
length
;
i
+=
g_bitstream
[
pos
].
length
;
pos
++
;
pos
++
;
...
@@ -121,7 +130,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -121,7 +130,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_writememory
(
dev
,
addr
,
buf
,
i
,
ANCHOR_LOAD_FPGA
);
err
=
emi26_writememory
(
dev
,
addr
,
buf
,
i
,
ANCHOR_LOAD_FPGA
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
}
while
(
i
>
0
);
}
while
(
i
>
0
);
...
@@ -129,7 +138,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -129,7 +138,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_set_reset
(
dev
,
1
);
err
=
emi26_set_reset
(
dev
,
1
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
/* 3. We need to put the loader for the firmware into the EZ-USB (again...) */
/* 3. We need to put the loader for the firmware into the EZ-USB (again...) */
...
@@ -137,7 +146,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -137,7 +146,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_writememory
(
dev
,
g_Loader
[
i
].
address
,
g_Loader
[
i
].
data
,
g_Loader
[
i
].
length
,
ANCHOR_LOAD_INTERNAL
);
err
=
emi26_writememory
(
dev
,
g_Loader
[
i
].
address
,
g_Loader
[
i
].
data
,
g_Loader
[
i
].
length
,
ANCHOR_LOAD_INTERNAL
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
}
}
...
@@ -145,7 +154,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -145,7 +154,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_set_reset
(
dev
,
0
);
err
=
emi26_set_reset
(
dev
,
0
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
/* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */
/* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */
...
@@ -154,7 +163,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -154,7 +163,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_writememory
(
dev
,
g_Firmware
[
i
].
address
,
g_Firmware
[
i
].
data
,
g_Firmware
[
i
].
length
,
ANCHOR_LOAD_EXTERNAL
);
err
=
emi26_writememory
(
dev
,
g_Firmware
[
i
].
address
,
g_Firmware
[
i
].
data
,
g_Firmware
[
i
].
length
,
ANCHOR_LOAD_EXTERNAL
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
}
}
}
}
...
@@ -163,7 +172,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -163,7 +172,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_set_reset
(
dev
,
1
);
err
=
emi26_set_reset
(
dev
,
1
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
for
(
i
=
0
;
g_Firmware
[
i
].
type
==
0
;
i
++
)
{
for
(
i
=
0
;
g_Firmware
[
i
].
type
==
0
;
i
++
)
{
...
@@ -171,7 +180,7 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -171,7 +180,7 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_writememory
(
dev
,
g_Firmware
[
i
].
address
,
g_Firmware
[
i
].
data
,
g_Firmware
[
i
].
length
,
ANCHOR_LOAD_INTERNAL
);
err
=
emi26_writememory
(
dev
,
g_Firmware
[
i
].
address
,
g_Firmware
[
i
].
data
,
g_Firmware
[
i
].
length
,
ANCHOR_LOAD_INTERNAL
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
}
}
}
}
...
@@ -180,12 +189,16 @@ static int emi26_load_firmware (struct usb_device *dev)
...
@@ -180,12 +189,16 @@ static int emi26_load_firmware (struct usb_device *dev)
err
=
emi26_set_reset
(
dev
,
0
);
err
=
emi26_set_reset
(
dev
,
0
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
err
(
"%s - error loading firmware: error = %d"
,
__FUNCTION__
,
err
);
return
err
;
goto
wrap
err
;
}
}
/* return 1 to fail the driver inialization
/* return 1 to fail the driver inialization
* and give real driver change to load */
* and give real driver change to load */
return
1
;
return
1
;
wraperr:
kfree
(
buf
);
return
err
;
}
}
static
__devinitdata
struct
usb_device_id
id_table
[]
=
{
static
__devinitdata
struct
usb_device_id
id_table
[]
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment