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
Kirill Smelkov
linux
Commits
b74d2576
Commit
b74d2576
authored
Jul 31, 2002
by
Patrick Mochel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert users of struct device_attribute to initialize the structs using
DEVICE_ATTR macro.
parent
8d1290b8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
52 additions
and
123 deletions
+52
-123
drivers/base/interface.c
drivers/base/interface.c
+5
-13
drivers/pci/proc.c
drivers/pci/proc.c
+4
-12
drivers/scsi/scsi_scan.c
drivers/scsi/scsi_scan.c
+2
-6
drivers/scsi/sg.c
drivers/scsi/sg.c
+6
-14
drivers/scsi/sr.c
drivers/scsi/sr.c
+4
-12
drivers/scsi/st.c
drivers/scsi/st.c
+10
-18
drivers/usb/core/usb.c
drivers/usb/core/usb.c
+11
-30
fs/partitions/check.c
fs/partitions/check.c
+10
-18
No files found.
drivers/base/interface.c
View file @
b74d2576
...
@@ -14,11 +14,7 @@ static ssize_t device_read_name(struct device * dev, char * buf, size_t count, l
...
@@ -14,11 +14,7 @@ static ssize_t device_read_name(struct device * dev, char * buf, size_t count, l
return
off
?
0
:
sprintf
(
buf
,
"%s
\n
"
,
dev
->
name
);
return
off
?
0
:
sprintf
(
buf
,
"%s
\n
"
,
dev
->
name
);
}
}
static
struct
device_attribute
device_name_entry
=
{
static
DEVICE_ATTR
(
name
,
"name"
,
S_IRUGO
,
device_read_name
,
NULL
);
name:
"name"
,
mode:
S_IRUGO
,
show:
device_read_name
,
};
static
ssize_t
static
ssize_t
device_read_power
(
struct
device
*
dev
,
char
*
page
,
size_t
count
,
loff_t
off
)
device_read_power
(
struct
device
*
dev
,
char
*
page
,
size_t
count
,
loff_t
off
)
...
@@ -89,15 +85,11 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o
...
@@ -89,15 +85,11 @@ device_write_power(struct device * dev, const char * buf, size_t count, loff_t o
return
error
<
0
?
error
:
count
;
return
error
<
0
?
error
:
count
;
}
}
static
struct
device_attribute
device_power_entry
=
{
static
DEVICE_ATTR
(
power
,
"power"
,
S_IWUSR
|
S_IRUGO
,
name:
"power"
,
device_read_power
,
device_write_power
);
mode:
S_IWUSR
|
S_IRUGO
,
show:
device_read_power
,
store:
device_write_power
,
};
struct
device_attribute
*
device_default_files
[]
=
{
struct
device_attribute
*
device_default_files
[]
=
{
&
dev
ice_name_entry
,
&
dev
_attr_name
,
&
dev
ice_power_entry
,
&
dev
_attr_power
,
NULL
,
NULL
,
};
};
drivers/pci/proc.c
View file @
b74d2576
...
@@ -378,11 +378,7 @@ static ssize_t pci_show_irq(struct device * dev, char * buf, size_t count, loff_
...
@@ -378,11 +378,7 @@ static ssize_t pci_show_irq(struct device * dev, char * buf, size_t count, loff_
return
off
?
0
:
sprintf
(
buf
,
"%u
\n
"
,
pci_dev
->
irq
);
return
off
?
0
:
sprintf
(
buf
,
"%u
\n
"
,
pci_dev
->
irq
);
}
}
static
struct
device_attribute
pci_irq_entry
=
{
static
DEVICE_ATTR
(
irq
,
"irq"
,
S_IRUGO
,
pci_show_irq
,
NULL
);
name:
"irq"
,
mode:
S_IRUGO
,
show:
pci_show_irq
,
};
static
ssize_t
pci_show_resources
(
struct
device
*
dev
,
char
*
buf
,
size_t
count
,
loff_t
off
)
static
ssize_t
pci_show_resources
(
struct
device
*
dev
,
char
*
buf
,
size_t
count
,
loff_t
off
)
{
{
...
@@ -406,11 +402,7 @@ static ssize_t pci_show_resources(struct device * dev, char * buf, size_t count,
...
@@ -406,11 +402,7 @@ static ssize_t pci_show_resources(struct device * dev, char * buf, size_t count,
return
(
str
-
buf
);
return
(
str
-
buf
);
}
}
static
struct
device_attribute
pci_resource_entry
=
{
static
DEVICE_ATTR
(
resource
,
"resource"
,
S_IRUGO
,
pci_show_resources
,
NULL
);
name:
"resources"
,
mode:
S_IRUGO
,
show:
pci_show_resources
,
};
int
pci_proc_attach_device
(
struct
pci_dev
*
dev
)
int
pci_proc_attach_device
(
struct
pci_dev
*
dev
)
{
{
...
@@ -432,8 +424,8 @@ int pci_proc_attach_device(struct pci_dev *dev)
...
@@ -432,8 +424,8 @@ int pci_proc_attach_device(struct pci_dev *dev)
e
->
data
=
dev
;
e
->
data
=
dev
;
e
->
size
=
PCI_CFG_SPACE_SIZE
;
e
->
size
=
PCI_CFG_SPACE_SIZE
;
device_create_file
(
&
dev
->
dev
,
&
pci_irq_entry
);
device_create_file
(
&
dev
->
dev
,
&
dev_attr_irq
);
device_create_file
(
&
dev
->
dev
,
&
pci_resource_entry
);
device_create_file
(
&
dev
->
dev
,
&
dev_attr_resource
);
return
0
;
return
0
;
}
}
...
...
drivers/scsi/scsi_scan.c
View file @
b74d2576
...
@@ -305,12 +305,8 @@ static ssize_t scsi_device_type_read(struct device *driverfs_dev, char *page,
...
@@ -305,12 +305,8 @@ static ssize_t scsi_device_type_read(struct device *driverfs_dev, char *page,
return
0
;
return
0
;
}
}
static
DEVICE_ATTR
(
type
,
"type"
,
S_IRUGO
,
scsi_device_type_read
,
NULL
);
static
struct
device_attribute
scsi_device_type_file
=
{
name:
"type"
,
mode:
S_IRUGO
,
show:
scsi_device_type_read
,
};
/* end content handlers */
/* end content handlers */
static
void
print_inquiry
(
unsigned
char
*
data
)
static
void
print_inquiry
(
unsigned
char
*
data
)
...
@@ -825,7 +821,7 @@ static int scan_scsis_single(unsigned int channel, unsigned int dev,
...
@@ -825,7 +821,7 @@ static int scan_scsis_single(unsigned int channel, unsigned int dev,
/* Create driverfs file entries */
/* Create driverfs file entries */
device_create_file
(
&
SDpnt
->
sdev_driverfs_dev
,
device_create_file
(
&
SDpnt
->
sdev_driverfs_dev
,
&
scsi_device_type_fil
e
);
&
dev_attr_typ
e
);
sprintf
(
devname
,
"host%d/bus%d/target%d/lun%d"
,
sprintf
(
devname
,
"host%d/bus%d/target%d/lun%d"
,
SDpnt
->
host
->
host_no
,
SDpnt
->
channel
,
SDpnt
->
id
,
SDpnt
->
lun
);
SDpnt
->
host
->
host_no
,
SDpnt
->
channel
,
SDpnt
->
id
,
SDpnt
->
lun
);
...
...
drivers/scsi/sg.c
View file @
b74d2576
...
@@ -1402,22 +1402,14 @@ static ssize_t sg_device_kdev_read(struct device *driverfs_dev, char *page,
...
@@ -1402,22 +1402,14 @@ static ssize_t sg_device_kdev_read(struct device *driverfs_dev, char *page,
Sg_device
*
sdp
=
list_entry
(
driverfs_dev
,
Sg_device
,
sg_driverfs_dev
);
Sg_device
*
sdp
=
list_entry
(
driverfs_dev
,
Sg_device
,
sg_driverfs_dev
);
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
sdp
->
i_rdev
.
value
);
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
sdp
->
i_rdev
.
value
);
}
}
static
struct
device_attribute
sg_device_kdev_file
=
{
static
DEVICE_ATTR
(
kdev
,
"kdev"
,
S_IRUGO
,
sg_device_kdev_read
,
NULL
);
name:
"kdev"
,
mode:
S_IRUGO
,
show:
sg_device_kdev_read
,
};
static
ssize_t
sg_device_type_read
(
struct
device
*
driverfs_dev
,
char
*
page
,
static
ssize_t
sg_device_type_read
(
struct
device
*
driverfs_dev
,
char
*
page
,
size_t
count
,
loff_t
off
)
size_t
count
,
loff_t
off
)
{
{
return
off
?
0
:
sprintf
(
page
,
"CHR
\n
"
);
return
off
?
0
:
sprintf
(
page
,
"CHR
\n
"
);
}
}
static
struct
device_attribute
sg_device_type_file
=
{
static
DEVICE_ATTR
(
type
,
"type"
,
S_IRUGO
,
sg_device_type_read
,
NULL
);
name:
"type"
,
mode:
S_IRUGO
,
show:
sg_device_type_read
,
};
static
int
sg_attach
(
Scsi_Device
*
scsidp
)
static
int
sg_attach
(
Scsi_Device
*
scsidp
)
{
{
...
@@ -1485,8 +1477,8 @@ static int sg_attach(Scsi_Device * scsidp)
...
@@ -1485,8 +1477,8 @@ static int sg_attach(Scsi_Device * scsidp)
sdp
->
sg_driverfs_dev
.
parent
=
&
scsidp
->
sdev_driverfs_dev
;
sdp
->
sg_driverfs_dev
.
parent
=
&
scsidp
->
sdev_driverfs_dev
;
sdp
->
sg_driverfs_dev
.
bus
=
&
scsi_driverfs_bus_type
;
sdp
->
sg_driverfs_dev
.
bus
=
&
scsi_driverfs_bus_type
;
device_register
(
&
sdp
->
sg_driverfs_dev
);
device_register
(
&
sdp
->
sg_driverfs_dev
);
device_create_file
(
&
sdp
->
sg_driverfs_dev
,
&
sg_device_type_fil
e
);
device_create_file
(
&
sdp
->
sg_driverfs_dev
,
&
dev_attr_typ
e
);
device_create_file
(
&
sdp
->
sg_driverfs_dev
,
&
sg_device_kdev_file
);
device_create_file
(
&
sdp
->
sg_driverfs_dev
,
&
dev_attr_kdev
);
sdp
->
de
=
devfs_register
(
scsidp
->
de
,
"generic"
,
DEVFS_FL_DEFAULT
,
sdp
->
de
=
devfs_register
(
scsidp
->
de
,
"generic"
,
DEVFS_FL_DEFAULT
,
SCSI_GENERIC_MAJOR
,
k
,
SCSI_GENERIC_MAJOR
,
k
,
...
@@ -1556,8 +1548,8 @@ static void sg_detach(Scsi_Device * scsidp)
...
@@ -1556,8 +1548,8 @@ static void sg_detach(Scsi_Device * scsidp)
}
}
SCSI_LOG_TIMEOUT
(
3
,
printk
(
"sg_detach: dev=%d, dirty
\n
"
,
k
));
SCSI_LOG_TIMEOUT
(
3
,
printk
(
"sg_detach: dev=%d, dirty
\n
"
,
k
));
devfs_unregister
(
sdp
->
de
);
devfs_unregister
(
sdp
->
de
);
device_remove_file
(
&
sdp
->
sg_driverfs_dev
,
&
sg_device_type_fil
e
);
device_remove_file
(
&
sdp
->
sg_driverfs_dev
,
&
dev_attr_typ
e
);
device_remove_file
(
&
sdp
->
sg_driverfs_dev
,
&
sg_device_kdev_file
);
device_remove_file
(
&
sdp
->
sg_driverfs_dev
,
&
dev_attr_kdev
);
put_device
(
&
sdp
->
sg_driverfs_dev
);
put_device
(
&
sdp
->
sg_driverfs_dev
);
sdp
->
de
=
NULL
;
sdp
->
de
=
NULL
;
if
(
NULL
==
sdp
->
headfp
)
{
if
(
NULL
==
sdp
->
headfp
)
{
...
...
drivers/scsi/sr.c
View file @
b74d2576
...
@@ -739,22 +739,14 @@ static ssize_t sr_device_kdev_read(struct device *driverfs_dev,
...
@@ -739,22 +739,14 @@ static ssize_t sr_device_kdev_read(struct device *driverfs_dev,
kdev
.
value
=
(
int
)
driverfs_dev
->
driver_data
;
kdev
.
value
=
(
int
)
driverfs_dev
->
driver_data
;
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
kdev
.
value
);
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
kdev
.
value
);
}
}
static
struct
device_attribute
sr_device_kdev_file
=
{
static
DEVICE_ATTR
(
kdev
,
"kdev"
,
S_IRUGO
,
sr_device_kdev_read
,
NULL
);
name:
"kdev"
,
mode:
S_IRUGO
,
show:
sr_device_kdev_read
,
};
static
ssize_t
sr_device_type_read
(
struct
device
*
driverfs_dev
,
static
ssize_t
sr_device_type_read
(
struct
device
*
driverfs_dev
,
char
*
page
,
size_t
count
,
loff_t
off
)
char
*
page
,
size_t
count
,
loff_t
off
)
{
{
return
off
?
0
:
sprintf
(
page
,
"CHR
\n
"
);
return
off
?
0
:
sprintf
(
page
,
"CHR
\n
"
);
}
}
static
struct
device_attribute
sr_device_type_file
=
{
static
DEVICE_ATTR
(
type
,
"type"
,
S_IRUGO
,
sr_device_type_read
,
NULL
);
name:
"type"
,
mode:
S_IRUGO
,
show:
sr_device_type_read
,
};
void
sr_finish
()
void
sr_finish
()
...
@@ -813,9 +805,9 @@ void sr_finish()
...
@@ -813,9 +805,9 @@ void sr_finish()
(
void
*
)
__mkdev
(
MAJOR_NR
,
i
);
(
void
*
)
__mkdev
(
MAJOR_NR
,
i
);
device_register
(
&
SCp
->
cdi
.
cdrom_driverfs_dev
);
device_register
(
&
SCp
->
cdi
.
cdrom_driverfs_dev
);
device_create_file
(
&
SCp
->
cdi
.
cdrom_driverfs_dev
,
device_create_file
(
&
SCp
->
cdi
.
cdrom_driverfs_dev
,
&
sr_device_type_fil
e
);
&
dev_attr_typ
e
);
device_create_file
(
&
SCp
->
cdi
.
cdrom_driverfs_dev
,
device_create_file
(
&
SCp
->
cdi
.
cdrom_driverfs_dev
,
&
sr_device_kdev_file
);
&
dev_attr_kdev
);
SCp
->
cdi
.
de
=
devfs_register
(
SCp
->
device
->
de
,
"cd"
,
SCp
->
cdi
.
de
=
devfs_register
(
SCp
->
device
->
de
,
"cd"
,
DEVFS_FL_DEFAULT
,
MAJOR_NR
,
i
,
DEVFS_FL_DEFAULT
,
MAJOR_NR
,
i
,
S_IFBLK
|
S_IRUGO
|
S_IWUGO
,
S_IFBLK
|
S_IRUGO
|
S_IWUGO
,
...
...
drivers/scsi/st.c
View file @
b74d2576
...
@@ -3533,22 +3533,14 @@ static ssize_t st_device_kdev_read(struct device *driverfs_dev,
...
@@ -3533,22 +3533,14 @@ static ssize_t st_device_kdev_read(struct device *driverfs_dev,
kdev
.
value
=
(
int
)
driverfs_dev
->
driver_data
;
kdev
.
value
=
(
int
)
driverfs_dev
->
driver_data
;
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
kdev
.
value
);
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
kdev
.
value
);
}
}
static
struct
device_attribute
st_device_kdev_file
=
{
static
DEVICE_ATTR
(
kdev
,
"kdev"
,
S_IRUGO
,
st_device_kdev_read
,
NULL
);
name:
"kdev"
,
mode:
S_IRUGO
,
show:
st_device_kdev_read
,
};
static
ssize_t
st_device_type_read
(
struct
device
*
driverfs_dev
,
static
ssize_t
st_device_type_read
(
struct
device
*
driverfs_dev
,
char
*
page
,
size_t
count
,
loff_t
off
)
char
*
page
,
size_t
count
,
loff_t
off
)
{
{
return
off
?
0
:
sprintf
(
page
,
"CHR
\n
"
);
return
off
?
0
:
sprintf
(
page
,
"CHR
\n
"
);
}
}
static
struct
device_attribute
st_device_type_file
=
{
static
DEVICE_ATTR
(
type
,
"type"
,
S_IRUGO
,
st_device_type_read
,
NULL
);
name:
"type"
,
mode:
S_IRUGO
,
show:
st_device_type_read
,
};
static
struct
file_operations
st_fops
=
static
struct
file_operations
st_fops
=
...
@@ -3664,8 +3656,8 @@ static int st_attach(Scsi_Device * SDp)
...
@@ -3664,8 +3656,8 @@ static int st_attach(Scsi_Device * SDp)
(
void
*
)
__mkdev
(
MAJOR_NR
,
i
+
(
mode
<<
5
));
(
void
*
)
__mkdev
(
MAJOR_NR
,
i
+
(
mode
<<
5
));
device_register
(
&
tpnt
->
driverfs_dev_r
[
mode
]);
device_register
(
&
tpnt
->
driverfs_dev_r
[
mode
]);
device_create_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
device_create_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
&
st_device_type_fil
e
);
&
dev_attr_typ
e
);
device_create_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
&
st_device_kdev_file
);
device_create_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
&
dev_attr_kdev
);
tpnt
->
de_r
[
mode
]
=
tpnt
->
de_r
[
mode
]
=
devfs_register
(
SDp
->
de
,
name
,
DEVFS_FL_DEFAULT
,
devfs_register
(
SDp
->
de
,
name
,
DEVFS_FL_DEFAULT
,
MAJOR_NR
,
i
+
(
mode
<<
5
),
MAJOR_NR
,
i
+
(
mode
<<
5
),
...
@@ -3683,9 +3675,9 @@ static int st_attach(Scsi_Device * SDp)
...
@@ -3683,9 +3675,9 @@ static int st_attach(Scsi_Device * SDp)
(
void
*
)
__mkdev
(
MAJOR_NR
,
i
+
(
mode
<<
5
)
+
128
);
(
void
*
)
__mkdev
(
MAJOR_NR
,
i
+
(
mode
<<
5
)
+
128
);
device_register
(
&
tpnt
->
driverfs_dev_n
[
mode
]);
device_register
(
&
tpnt
->
driverfs_dev_n
[
mode
]);
device_create_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
device_create_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
&
st_device_type_fil
e
);
&
dev_attr_typ
e
);
device_create_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
device_create_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
&
st_device_kdev_file
);
&
dev_attr_kdev
);
tpnt
->
de_n
[
mode
]
=
tpnt
->
de_n
[
mode
]
=
devfs_register
(
SDp
->
de
,
name
,
DEVFS_FL_DEFAULT
,
devfs_register
(
SDp
->
de
,
name
,
DEVFS_FL_DEFAULT
,
MAJOR_NR
,
i
+
(
mode
<<
5
)
+
128
,
MAJOR_NR
,
i
+
(
mode
<<
5
)
+
128
,
...
@@ -3785,16 +3777,16 @@ static void st_detach(Scsi_Device * SDp)
...
@@ -3785,16 +3777,16 @@ static void st_detach(Scsi_Device * SDp)
devfs_unregister
(
tpnt
->
de_r
[
mode
]);
devfs_unregister
(
tpnt
->
de_r
[
mode
]);
tpnt
->
de_r
[
mode
]
=
NULL
;
tpnt
->
de_r
[
mode
]
=
NULL
;
device_remove_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
device_remove_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
&
st_device_type_fil
e
);
&
dev_attr_typ
e
);
device_remove_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
device_remove_file
(
&
tpnt
->
driverfs_dev_r
[
mode
],
&
st_device_kdev_fil
e
);
&
dev_attr_typ
e
);
put_device
(
&
tpnt
->
driverfs_dev_r
[
mode
]);
put_device
(
&
tpnt
->
driverfs_dev_r
[
mode
]);
devfs_unregister
(
tpnt
->
de_n
[
mode
]);
devfs_unregister
(
tpnt
->
de_n
[
mode
]);
tpnt
->
de_n
[
mode
]
=
NULL
;
tpnt
->
de_n
[
mode
]
=
NULL
;
device_remove_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
device_remove_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
st_device_type_file
.
nam
e
);
&
dev_attr_typ
e
);
device_remove_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
device_remove_file
(
&
tpnt
->
driverfs_dev_n
[
mode
],
st_device_kdev_file
.
name
);
&
dev_attr_kdev
);
put_device
(
&
tpnt
->
driverfs_dev_n
[
mode
]);
put_device
(
&
tpnt
->
driverfs_dev_n
[
mode
]);
}
}
if
(
tpnt
->
buffer
)
{
if
(
tpnt
->
buffer
)
{
...
...
drivers/usb/core/usb.c
View file @
b74d2576
...
@@ -835,11 +835,8 @@ show_config (struct device *dev, char *buf, size_t count, loff_t off)
...
@@ -835,11 +835,8 @@ show_config (struct device *dev, char *buf, size_t count, loff_t off)
udev
=
to_usb_device
(
dev
);
udev
=
to_usb_device
(
dev
);
return
sprintf
(
buf
,
"%u
\n
"
,
udev
->
actconfig
->
bConfigurationValue
);
return
sprintf
(
buf
,
"%u
\n
"
,
udev
->
actconfig
->
bConfigurationValue
);
}
}
static
struct
device_attribute
usb_config_entry
=
{
.
name
=
"configuration"
,
static
DEVICE_ATTR
(
config
,
"configuration"
,
S_IRUGO
,
show_config
,
NULL
);
.
mode
=
S_IRUGO
,
.
show
=
show_config
,
};
/* interfaces have one current setting; alternates
/* interfaces have one current setting; alternates
* can have different endpoints and class info.
* can have different endpoints and class info.
...
@@ -854,11 +851,7 @@ show_altsetting (struct device *dev, char *buf, size_t count, loff_t off)
...
@@ -854,11 +851,7 @@ show_altsetting (struct device *dev, char *buf, size_t count, loff_t off)
interface
=
to_usb_interface
(
dev
);
interface
=
to_usb_interface
(
dev
);
return
sprintf
(
buf
,
"%u
\n
"
,
interface
->
altsetting
->
bAlternateSetting
);
return
sprintf
(
buf
,
"%u
\n
"
,
interface
->
altsetting
->
bAlternateSetting
);
}
}
static
struct
device_attribute
usb_altsetting_entry
=
{
static
DEVICE_ATTR
(
altsetting
,
"altsetting"
,
S_IRUGO
,
show_altsetting
,
NULL
);
.
name
=
"altsetting"
,
.
mode
=
S_IRUGO
,
.
show
=
show_altsetting
,
};
/* product driverfs file */
/* product driverfs file */
static
ssize_t
show_product
(
struct
device
*
dev
,
char
*
buf
,
size_t
count
,
loff_t
off
)
static
ssize_t
show_product
(
struct
device
*
dev
,
char
*
buf
,
size_t
count
,
loff_t
off
)
...
@@ -875,11 +868,7 @@ static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t
...
@@ -875,11 +868,7 @@ static ssize_t show_product (struct device *dev, char *buf, size_t count, loff_t
buf
[
len
+
1
]
=
0x00
;
buf
[
len
+
1
]
=
0x00
;
return
len
+
1
;
return
len
+
1
;
}
}
static
struct
device_attribute
usb_product_entry
=
{
static
DEVICE_ATTR
(
product
,
"product"
,
S_IRUGO
,
show_product
,
NULL
);
.
name
=
"product"
,
.
mode
=
S_IRUGO
,
.
show
=
show_product
,
};
/* manufacturer driverfs file */
/* manufacturer driverfs file */
static
ssize_t
static
ssize_t
...
@@ -897,11 +886,7 @@ show_manufacturer (struct device *dev, char *buf, size_t count, loff_t off)
...
@@ -897,11 +886,7 @@ show_manufacturer (struct device *dev, char *buf, size_t count, loff_t off)
buf
[
len
+
1
]
=
0x00
;
buf
[
len
+
1
]
=
0x00
;
return
len
+
1
;
return
len
+
1
;
}
}
static
struct
device_attribute
usb_manufacturer_entry
=
{
static
DEVICE_ATTR
(
manufacturer
,
"manufacturer"
,
S_IRUGO
,
show_manufacturer
,
NULL
);
.
name
=
"manufacturer"
,
.
mode
=
S_IRUGO
,
.
show
=
show_manufacturer
,
};
/* serial number driverfs file */
/* serial number driverfs file */
static
ssize_t
static
ssize_t
...
@@ -919,11 +904,7 @@ show_serial (struct device *dev, char *buf, size_t count, loff_t off)
...
@@ -919,11 +904,7 @@ show_serial (struct device *dev, char *buf, size_t count, loff_t off)
buf
[
len
+
1
]
=
0x00
;
buf
[
len
+
1
]
=
0x00
;
return
len
+
1
;
return
len
+
1
;
}
}
static
struct
device_attribute
usb_serial_entry
=
{
static
DEVICE_ATTR
(
serial
,
"serial"
,
S_IRUGO
,
show_serial
,
NULL
);
.
name
=
"serial"
,
.
mode
=
S_IRUGO
,
.
show
=
show_serial
,
};
/*
/*
* This entrypoint gets called for each new device.
* This entrypoint gets called for each new device.
...
@@ -965,7 +946,7 @@ static void usb_find_drivers(struct usb_device *dev)
...
@@ -965,7 +946,7 @@ static void usb_find_drivers(struct usb_device *dev)
interface
->
altsetting
->
bInterfaceNumber
);
interface
->
altsetting
->
bInterfaceNumber
);
}
}
device_register
(
&
interface
->
dev
);
device_register
(
&
interface
->
dev
);
device_create_file
(
&
interface
->
dev
,
&
usb_altsetting_entry
);
device_create_file
(
&
interface
->
dev
,
&
dev_attr_altsetting
);
/* if this interface hasn't already been claimed */
/* if this interface hasn't already been claimed */
if
(
!
usb_interface_claimed
(
interface
))
{
if
(
!
usb_interface_claimed
(
interface
))
{
...
@@ -1453,13 +1434,13 @@ int usb_new_device(struct usb_device *dev)
...
@@ -1453,13 +1434,13 @@ int usb_new_device(struct usb_device *dev)
err
=
device_register
(
&
dev
->
dev
);
err
=
device_register
(
&
dev
->
dev
);
if
(
err
)
if
(
err
)
return
err
;
return
err
;
device_create_file
(
&
dev
->
dev
,
&
usb_config_entry
);
device_create_file
(
&
dev
->
dev
,
&
dev_attr_config
);
if
(
dev
->
descriptor
.
iManufacturer
)
if
(
dev
->
descriptor
.
iManufacturer
)
device_create_file
(
&
dev
->
dev
,
&
usb_manufacturer_entry
);
device_create_file
(
&
dev
->
dev
,
&
dev_attr_manufacturer
);
if
(
dev
->
descriptor
.
iProduct
)
if
(
dev
->
descriptor
.
iProduct
)
device_create_file
(
&
dev
->
dev
,
&
usb_product_entry
);
device_create_file
(
&
dev
->
dev
,
&
dev_attr_product
);
if
(
dev
->
descriptor
.
iSerialNumber
)
if
(
dev
->
descriptor
.
iSerialNumber
)
device_create_file
(
&
dev
->
dev
,
&
usb_serial_entry
);
device_create_file
(
&
dev
->
dev
,
&
dev_attr_serial
);
/* now that the basic setup is over, add a /proc/bus/usb entry */
/* now that the basic setup is over, add a /proc/bus/usb entry */
usbfs_add_device
(
dev
);
usbfs_add_device
(
dev
);
...
...
fs/partitions/check.c
View file @
b74d2576
...
@@ -210,22 +210,14 @@ static ssize_t partition_device_kdev_read(struct device *driverfs_dev,
...
@@ -210,22 +210,14 @@ static ssize_t partition_device_kdev_read(struct device *driverfs_dev,
kdev
.
value
=
(
int
)(
long
)
driverfs_dev
->
driver_data
;
kdev
.
value
=
(
int
)(
long
)
driverfs_dev
->
driver_data
;
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
kdev
.
value
);
return
off
?
0
:
sprintf
(
page
,
"%x
\n
"
,
kdev
.
value
);
}
}
static
struct
device_attribute
partition_device_kdev_file
=
{
static
DEVICE_ATTR
(
kdev
,
"kdev"
,
S_IRUGO
,
partition_device_kdev_read
,
NULL
);
name:
"kdev"
,
mode:
S_IRUGO
,
show:
partition_device_kdev_read
,
};
static
ssize_t
partition_device_type_read
(
struct
device
*
driverfs_dev
,
static
ssize_t
partition_device_type_read
(
struct
device
*
driverfs_dev
,
char
*
page
,
size_t
count
,
loff_t
off
)
char
*
page
,
size_t
count
,
loff_t
off
)
{
{
return
off
?
0
:
sprintf
(
page
,
"BLK
\n
"
);
return
off
?
0
:
sprintf
(
page
,
"BLK
\n
"
);
}
}
static
struct
device_attribute
partition_device_type_file
=
{
static
DEVICE_ATTR
(
type
,
"type"
,
S_IRUGO
,
partition_device_type_read
,
NULL
);
name:
"type"
,
mode:
S_IRUGO
,
show:
partition_device_type_read
,
};
void
driverfs_create_partitions
(
struct
gendisk
*
hd
,
int
minor
)
void
driverfs_create_partitions
(
struct
gendisk
*
hd
,
int
minor
)
{
{
...
@@ -296,9 +288,9 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
...
@@ -296,9 +288,9 @@ void driverfs_create_partitions(struct gendisk *hd, int minor)
if
(
parent
)
current_driverfs_dev
->
bus
=
parent
->
bus
;
if
(
parent
)
current_driverfs_dev
->
bus
=
parent
->
bus
;
device_register
(
current_driverfs_dev
);
device_register
(
current_driverfs_dev
);
device_create_file
(
current_driverfs_dev
,
device_create_file
(
current_driverfs_dev
,
&
partition_device_type_fil
e
);
&
dev_attr_typ
e
);
device_create_file
(
current_driverfs_dev
,
device_create_file
(
current_driverfs_dev
,
&
partition_device_kdev_file
);
&
dev_attr_kdev
);
}
}
}
}
}
}
...
@@ -317,17 +309,17 @@ void driverfs_remove_partitions(struct gendisk *hd, int minor)
...
@@ -317,17 +309,17 @@ void driverfs_remove_partitions(struct gendisk *hd, int minor)
if
((
p
[
part
].
nr_sects
>=
1
))
{
if
((
p
[
part
].
nr_sects
>=
1
))
{
current_driverfs_dev
=
&
p
[
part
].
hd_driverfs_dev
;
current_driverfs_dev
=
&
p
[
part
].
hd_driverfs_dev
;
device_remove_file
(
current_driverfs_dev
,
device_remove_file
(
current_driverfs_dev
,
&
partition_device_type_fil
e
);
&
dev_attr_typ
e
);
device_remove_file
(
current_driverfs_dev
,
device_remove_file
(
current_driverfs_dev
,
&
partition_device_kdev_file
);
&
dev_attr_kdev
);
put_device
(
current_driverfs_dev
);
put_device
(
current_driverfs_dev
);
}
}
}
}
current_driverfs_dev
=
&
p
->
hd_driverfs_dev
;
current_driverfs_dev
=
&
p
->
hd_driverfs_dev
;
device_remove_file
(
current_driverfs_dev
,
device_remove_file
(
current_driverfs_dev
,
&
partition_device_type_fil
e
);
&
dev_attr_typ
e
);
device_remove_file
(
current_driverfs_dev
,
device_remove_file
(
current_driverfs_dev
,
&
partition_device_kdev_file
);
&
dev_attr_kdev
);
put_device
(
current_driverfs_dev
);
put_device
(
current_driverfs_dev
);
return
;
return
;
}
}
...
...
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