Skip to content

Commit fffe52e

Browse files
Geert UytterhoevenLinus Torvalds
authored andcommitted
ps3av: misc updates
ps3av: - Move the definition of struct ps3av to ps3av.c, as it's locally used only. - Kill ps3av.sem, use the existing ps3av.mutex instead. - Make the 512-byte buffer in ps3av_do_pkt() static to reduce stack usage. Its use is protected by a semaphore anyway. Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bd685ac commit fffe52e

2 files changed

Lines changed: 23 additions & 28 deletions

File tree

‎drivers/ps3/ps3av.c‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,24 @@
3838
static int timeout = 5000; /* in msec ( 5 sec ) */
3939
module_param(timeout, int, 0644);
4040

41-
static struct ps3av ps3av;
41+
static struct ps3av {
42+
int available;
43+
struct mutex mutex;
44+
struct work_struct work;
45+
struct completion done;
46+
struct workqueue_struct *wq;
47+
int open_count;
48+
struct ps3_vuart_port_device *dev;
49+
50+
int region;
51+
struct ps3av_pkt_av_get_hw_conf av_hw_conf;
52+
u32 av_port[PS3AV_AV_PORT_MAX + PS3AV_OPT_PORT_MAX];
53+
u32 opt_port[PS3AV_OPT_PORT_MAX];
54+
u32 head[PS3AV_HEAD_MAX];
55+
u32 audio_port;
56+
int ps3av_mode;
57+
int ps3av_mode_old;
58+
} ps3av;
4259

4360
static struct ps3_vuart_port_device ps3av_dev = {
4461
.match_id = PS3_MATCH_ID_AV_SETTINGS
@@ -250,7 +267,7 @@ int ps3av_do_pkt(u32 cid, u16 send_len, size_t usr_buf_size,
250267
struct ps3av_send_hdr *buf)
251268
{
252269
int res = 0;
253-
union {
270+
static union {
254271
struct ps3av_reply_hdr reply_hdr;
255272
u8 raw[PS3AV_BUF_SIZE];
256273
} recv_buf;
@@ -259,8 +276,7 @@ int ps3av_do_pkt(u32 cid, u16 send_len, size_t usr_buf_size,
259276

260277
BUG_ON(!ps3av.available);
261278

262-
if (down_interruptible(&ps3av.sem))
263-
return -ERESTARTSYS;
279+
mutex_lock(&ps3av.mutex);
264280

265281
table = ps3av_search_cmd_table(cid, PS3AV_CID_MASK);
266282
BUG_ON(!table);
@@ -290,11 +306,11 @@ int ps3av_do_pkt(u32 cid, u16 send_len, size_t usr_buf_size,
290306
goto err;
291307
}
292308

293-
up(&ps3av.sem);
309+
mutex_unlock(&ps3av.mutex);
294310
return 0;
295311

296312
err:
297-
up(&ps3av.sem);
313+
mutex_unlock(&ps3av.mutex);
298314
printk(KERN_ERR "%s: failed cid:%x res:%d\n", __FUNCTION__, cid, res);
299315
return res;
300316
}
@@ -872,7 +888,6 @@ static int ps3av_probe(struct ps3_vuart_port_device *dev)
872888

873889
memset(&ps3av, 0, sizeof(ps3av));
874890

875-
init_MUTEX(&ps3av.sem);
876891
mutex_init(&ps3av.mutex);
877892
ps3av.ps3av_mode = 0;
878893
ps3av.dev = dev;

‎include/asm-powerpc/ps3av.h‎

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#ifndef _ASM_POWERPC_PS3AV_H_
1919
#define _ASM_POWERPC_PS3AV_H_
2020

21-
#include <linux/mutex.h>
22-
2321
/** command for ioctl() **/
2422
#define PS3AV_VERSION 0x205 /* version of ps3av command */
2523

@@ -643,25 +641,6 @@ struct ps3av_pkt_avb_param {
643641
u8 buf[PS3AV_PKT_AVB_PARAM_MAX_BUF_SIZE];
644642
};
645643

646-
struct ps3av {
647-
int available;
648-
struct semaphore sem;
649-
struct work_struct work;
650-
struct completion done;
651-
struct workqueue_struct *wq;
652-
struct mutex mutex;
653-
int open_count;
654-
struct ps3_vuart_port_device *dev;
655-
656-
int region;
657-
struct ps3av_pkt_av_get_hw_conf av_hw_conf;
658-
u32 av_port[PS3AV_AV_PORT_MAX + PS3AV_OPT_PORT_MAX];
659-
u32 opt_port[PS3AV_OPT_PORT_MAX];
660-
u32 head[PS3AV_HEAD_MAX];
661-
u32 audio_port;
662-
int ps3av_mode;
663-
int ps3av_mode_old;
664-
};
665644

666645
/** command status **/
667646
#define PS3AV_STATUS_SUCCESS 0x0000 /* success */
@@ -719,6 +698,7 @@ static inline void ps3av_cmd_av_monitor_info_dump(const struct ps3av_pkt_av_get_
719698
extern int ps3av_cmd_video_get_monitor_info(struct ps3av_pkt_av_get_monitor_info *,
720699
u32);
721700

701+
struct ps3_vuart_port_device;
722702
extern int ps3av_vuart_write(struct ps3_vuart_port_device *dev,
723703
const void *buf, unsigned long size);
724704
extern int ps3av_vuart_read(struct ps3_vuart_port_device *dev, void *buf,

0 commit comments

Comments
 (0)