Skip to content

Commit

Permalink
rapidio: fix sysfs config attribute to access 16MB of maint space
Browse files Browse the repository at this point in the history
Fixes sysfs config attribute to allow access to entire 16MB maintenance
space of RapidIO devices.

Signed-off-by: Alexandre Bounine <[email protected]>
Cc: Kumar Gala <[email protected]>
Cc: Matt Porter <[email protected]>
Cc: Li Yang <[email protected]>
Cc: Thomas Moll <[email protected]>
Cc: Micha Nelissen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Alexandre Bounine authored and torvalds committed Feb 25, 2011
1 parent 99b0d36 commit fe41947
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions drivers/rapidio/rio-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ rio_read_config(struct file *filp, struct kobject *kobj,

/* Several chips lock up trying to read undefined config space */
if (capable(CAP_SYS_ADMIN))
size = 0x200000;
size = RIO_MAINT_SPACE_SZ;

if (off > size)
if (off >= size)
return 0;
if (off + count > size) {
size -= off;
Expand Down Expand Up @@ -147,10 +147,10 @@ rio_write_config(struct file *filp, struct kobject *kobj,
loff_t init_off = off;
u8 *data = (u8 *) buf;

if (off > 0x200000)
if (off >= RIO_MAINT_SPACE_SZ)
return 0;
if (off + count > 0x200000) {
size = 0x200000 - off;
if (off + count > RIO_MAINT_SPACE_SZ) {
size = RIO_MAINT_SPACE_SZ - off;
count = size;
}

Expand Down Expand Up @@ -200,7 +200,7 @@ static struct bin_attribute rio_config_attr = {
.name = "config",
.mode = S_IRUGO | S_IWUSR,
},
.size = 0x200000,
.size = RIO_MAINT_SPACE_SZ,
.read = rio_read_config,
.write = rio_write_config,
};
Expand Down
4 changes: 3 additions & 1 deletion include/linux/rio_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
#define LINUX_RIO_REGS_H

/*
* In RapidIO, each device has a 2MB configuration space that is
* In RapidIO, each device has a 16MB configuration space that is
* accessed via maintenance transactions. Portions of configuration
* space are standardized and/or reserved.
*/
#define RIO_MAINT_SPACE_SZ 0x1000000 /* 16MB of RapidIO mainenance space */

#define RIO_DEV_ID_CAR 0x00 /* [I] Device Identity CAR */
#define RIO_DEV_INFO_CAR 0x04 /* [I] Device Information CAR */
#define RIO_ASM_ID_CAR 0x08 /* [I] Assembly Identity CAR */
Expand Down

0 comments on commit fe41947

Please sign in to comment.