Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC TDC 1ns 5cha
Commits
22b3ec33
Commit
22b3ec33
authored
Feb 02, 2023
by
Vaibhav Gupta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! software: kernel: Use HWMON API to expose Temperature
parent
3682c317
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
19 deletions
+28
-19
fmc-tdc.h
software/kernel/fmc-tdc.h
+3
-1
ft-hwmon.c
software/kernel/ft-hwmon.c
+25
-18
No files found.
software/kernel/fmc-tdc.h
View file @
22b3ec33
...
...
@@ -254,9 +254,11 @@ struct fmctdc_dev {
/* next temperature measurement pending? */
unsigned
long
next_t
;
/* temperature, degrees Celsius scaled by 16 and its ready flag */
struct
device
*
hwmon_dev
;
int
temp
;
int
temp_ready
;
char
*
hwmon_temp_sensor_id
;
struct
device
*
hwmon_dev
;
/* output lots of debug stuff? */
struct
ft_channel_state
channels
[
FT_NUM_CHANNELS
];
int
wr_mode
;
...
...
software/kernel/ft-hwmon.c
View file @
22b3ec33
...
...
@@ -3,6 +3,8 @@
/*
* Author: Vaibhav Gupta <vaibhav.gupta@cern.ch>
*
* Hardware Monitoring for ft-dev
*/
#include <linux/hwmon.h>
...
...
@@ -30,29 +32,13 @@ static int ft_hwmon_temp_read(struct device *dev, enum hwmon_sensor_types type,
return
0
;
}
static
char
*
ft_hwmon_temp_sensor_id
;
static
int
ft_hwmon_temp_sensor_id_read
(
struct
device
*
dev
,
enum
hwmon_sensor_types
type
,
u32
attr
,
int
channel
,
const
char
**
str
)
{
int
size
;
char
device_type
[]
=
"Temperature - FMC TDC - "
;
struct
fmctdc_dev
*
ft
=
dev_get_drvdata
(
dev
);
size
=
strlen
(
dev_name
(
&
ft
->
slot
->
dev
));
size
+=
strlen
(
device_type
);
size
++
;
ft_hwmon_temp_sensor_id
=
kzalloc
(
size
,
GFP_KERNEL
);
if
(
!
ft_hwmon_temp_sensor_id
)
return
-
ENOMEM
;
snprintf
(
ft_hwmon_temp_sensor_id
,
size
,
"%s%s"
,
device_type
,
dev_name
(
&
ft
->
slot
->
dev
));
*
str
=
ft_hwmon_temp_sensor_id
;
*
str
=
ft
->
hwmon_temp_sensor_id
;
return
0
;
}
...
...
@@ -75,13 +61,34 @@ static const struct hwmon_chip_info ft_hwmon_temp_chip_info = {
int
ft_hwmon_init
(
struct
fmctdc_dev
*
ft
)
{
int
size
;
char
device_type
[]
=
"Temperature - FMC TDC 1NS 5CHA - "
;
struct
device
*
dev
=
&
ft
->
pdev
->
dev
;
ft
->
hwmon_dev
=
devm_hwmon_device_register_with_info
(
dev
,
"ft_temperature"
,
ft
,
&
ft_hwmon_temp_chip_info
,
NULL
);
return
PTR_ERR_OR_ZERO
(
ft
->
hwmon_dev
);
if
(
!
IS_ERR
(
ft
->
hwmon_dev
))
{
size
=
strlen
(
dev_name
(
&
ft
->
slot
->
dev
));
size
+=
strlen
(
device_type
);
size
++
;
ft
->
hwmon_temp_sensor_id
=
devm_kzalloc
(
ft
->
hwmon_dev
,
size
,
GFP_KERNEL
);
if
(
!
ft
->
hwmon_temp_sensor_id
)
{
devm_hwmon_device_unregister
(
dev
);
return
-
ENOMEM
;
}
snprintf
(
ft
->
hwmon_temp_sensor_id
,
size
,
"%s%s"
,
device_type
,
dev_name
(
&
ft
->
slot
->
dev
));
return
0
;
}
return
PTR_ERR
(
ft
->
hwmon_dev
);
}
#endif
/* LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,0) */
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