Skip to content

Commit ba6354f

Browse files
committed
Merge tag 'char-misc-5.17-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fix from Greg KH: "Here is a single driver fix for 5.17-final that has been submitted many times but I somehow missed it in my patch queue: - fix for counter sysfs code for reported problem This has been in linux-next all week with no reported issues" * tag 'char-misc-5.17-final' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: counter: Stop using dev_get_drvdata() to get the counter device
2 parents 6aa61c1 + 01b44ef commit ba6354f

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

drivers/counter/counter-sysfs.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
#include "counter-sysfs.h"
2121

22+
static inline struct counter_device *counter_from_dev(struct device *dev)
23+
{
24+
return container_of(dev, struct counter_device, dev);
25+
}
26+
2227
/**
2328
* struct counter_attribute - Counter sysfs attribute
2429
* @dev_attr: device attribute for sysfs
@@ -90,7 +95,7 @@ static ssize_t counter_comp_u8_show(struct device *dev,
9095
struct device_attribute *attr, char *buf)
9196
{
9297
const struct counter_attribute *const a = to_counter_attribute(attr);
93-
struct counter_device *const counter = dev_get_drvdata(dev);
98+
struct counter_device *const counter = counter_from_dev(dev);
9499
int err;
95100
u8 data = 0;
96101

@@ -122,7 +127,7 @@ static ssize_t counter_comp_u8_store(struct device *dev,
122127
const char *buf, size_t len)
123128
{
124129
const struct counter_attribute *const a = to_counter_attribute(attr);
125-
struct counter_device *const counter = dev_get_drvdata(dev);
130+
struct counter_device *const counter = counter_from_dev(dev);
126131
int err;
127132
bool bool_data = 0;
128133
u8 data = 0;
@@ -158,7 +163,7 @@ static ssize_t counter_comp_u32_show(struct device *dev,
158163
struct device_attribute *attr, char *buf)
159164
{
160165
const struct counter_attribute *const a = to_counter_attribute(attr);
161-
struct counter_device *const counter = dev_get_drvdata(dev);
166+
struct counter_device *const counter = counter_from_dev(dev);
162167
const struct counter_available *const avail = a->comp.priv;
163168
int err;
164169
u32 data = 0;
@@ -221,7 +226,7 @@ static ssize_t counter_comp_u32_store(struct device *dev,
221226
const char *buf, size_t len)
222227
{
223228
const struct counter_attribute *const a = to_counter_attribute(attr);
224-
struct counter_device *const counter = dev_get_drvdata(dev);
229+
struct counter_device *const counter = counter_from_dev(dev);
225230
struct counter_count *const count = a->parent;
226231
struct counter_synapse *const synapse = a->comp.priv;
227232
const struct counter_available *const avail = a->comp.priv;
@@ -281,7 +286,7 @@ static ssize_t counter_comp_u64_show(struct device *dev,
281286
struct device_attribute *attr, char *buf)
282287
{
283288
const struct counter_attribute *const a = to_counter_attribute(attr);
284-
struct counter_device *const counter = dev_get_drvdata(dev);
289+
struct counter_device *const counter = counter_from_dev(dev);
285290
int err;
286291
u64 data = 0;
287292

@@ -309,7 +314,7 @@ static ssize_t counter_comp_u64_store(struct device *dev,
309314
const char *buf, size_t len)
310315
{
311316
const struct counter_attribute *const a = to_counter_attribute(attr);
312-
struct counter_device *const counter = dev_get_drvdata(dev);
317+
struct counter_device *const counter = counter_from_dev(dev);
313318
int err;
314319
u64 data = 0;
315320

0 commit comments

Comments
 (0)