Skip to content

Commit 327b3a0

Browse files
author
Izabela Bakollari
committed
Merge remote-tracking branch 'origin/merge-requests/1244' into realtek-hwmon
2 parents 229b334 + d499436 commit 327b3a0

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

drivers/hwmon/hwmon.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ static const struct class hwmon_class = {
145145

146146
static DEFINE_IDA(hwmon_ida);
147147

148+
static umode_t hwmon_is_visible(const struct hwmon_ops *ops,
149+
const void *drvdata,
150+
enum hwmon_sensor_types type,
151+
u32 attr, int channel)
152+
{
153+
if (ops->visible)
154+
return ops->visible;
155+
156+
return ops->is_visible(drvdata, type, attr, channel);
157+
}
158+
148159
/* Thermal zone handling */
149160

150161
/*
@@ -267,8 +278,8 @@ static int hwmon_thermal_register_sensors(struct device *dev)
267278
int err;
268279

269280
if (!(info[i]->config[j] & HWMON_T_INPUT) ||
270-
!chip->ops->is_visible(drvdata, hwmon_temp,
271-
hwmon_temp_input, j))
281+
!hwmon_is_visible(chip->ops, drvdata, hwmon_temp,
282+
hwmon_temp_input, j))
272283
continue;
273284

274285
err = hwmon_thermal_add_sensor(dev, j);
@@ -506,7 +517,7 @@ static struct attribute *hwmon_genattr(const void *drvdata,
506517
const char *name;
507518
bool is_string = is_string_attr(type, attr);
508519

509-
mode = ops->is_visible(drvdata, type, attr, index);
520+
mode = hwmon_is_visible(ops, drvdata, type, attr, index);
510521
if (!mode)
511522
return ERR_PTR(-ENOENT);
512523

@@ -1033,7 +1044,7 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
10331044
if (!dev || !name || !chip)
10341045
return ERR_PTR(-EINVAL);
10351046

1036-
if (!chip->ops || !chip->ops->is_visible || !chip->info)
1047+
if (!chip->ops || !(chip->ops->visible || chip->ops->is_visible) || !chip->info)
10371048
return ERR_PTR(-EINVAL);
10381049

10391050
return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);

include/linux/hwmon.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ enum hwmon_intrusion_attributes {
368368

369369
/**
370370
* struct hwmon_ops - hwmon device operations
371-
* @is_visible: Callback to return attribute visibility. Mandatory.
371+
* @visible: Static visibility. If non-zero, 'is_visible' is ignored.
372+
* @is_visible: Callback to return attribute visibility. Mandatory unless
373+
* 'visible' is non-zero.
372374
* Parameters are:
373375
* @const void *drvdata:
374376
* Pointer to driver-private data structure passed
@@ -412,6 +414,7 @@ enum hwmon_intrusion_attributes {
412414
* The function returns 0 on success or a negative error number.
413415
*/
414416
struct hwmon_ops {
417+
umode_t visible;
415418
umode_t (*is_visible)(const void *drvdata, enum hwmon_sensor_types type,
416419
u32 attr, int channel);
417420
int (*read)(struct device *dev, enum hwmon_sensor_types type,

0 commit comments

Comments
 (0)