Skip to content

Commit

Permalink
Merge tag 'char-misc-5.17-final' of git:https://git.kernel.org/pub/scm/linu…
Browse files Browse the repository at this point in the history
…x/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:https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
  counter: Stop using dev_get_drvdata() to get the counter device
  • Loading branch information
torvalds committed Mar 19, 2022
2 parents 6aa61c1 + 01b44ef commit ba6354f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions drivers/counter/counter-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@

#include "counter-sysfs.h"

static inline struct counter_device *counter_from_dev(struct device *dev)
{
return container_of(dev, struct counter_device, dev);
}

/**
* struct counter_attribute - Counter sysfs attribute
* @dev_attr: device attribute for sysfs
Expand Down Expand Up @@ -90,7 +95,7 @@ static ssize_t counter_comp_u8_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct counter_attribute *const a = to_counter_attribute(attr);
struct counter_device *const counter = dev_get_drvdata(dev);
struct counter_device *const counter = counter_from_dev(dev);
int err;
u8 data = 0;

Expand Down Expand Up @@ -122,7 +127,7 @@ static ssize_t counter_comp_u8_store(struct device *dev,
const char *buf, size_t len)
{
const struct counter_attribute *const a = to_counter_attribute(attr);
struct counter_device *const counter = dev_get_drvdata(dev);
struct counter_device *const counter = counter_from_dev(dev);
int err;
bool bool_data = 0;
u8 data = 0;
Expand Down Expand Up @@ -158,7 +163,7 @@ static ssize_t counter_comp_u32_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct counter_attribute *const a = to_counter_attribute(attr);
struct counter_device *const counter = dev_get_drvdata(dev);
struct counter_device *const counter = counter_from_dev(dev);
const struct counter_available *const avail = a->comp.priv;
int err;
u32 data = 0;
Expand Down Expand Up @@ -221,7 +226,7 @@ static ssize_t counter_comp_u32_store(struct device *dev,
const char *buf, size_t len)
{
const struct counter_attribute *const a = to_counter_attribute(attr);
struct counter_device *const counter = dev_get_drvdata(dev);
struct counter_device *const counter = counter_from_dev(dev);
struct counter_count *const count = a->parent;
struct counter_synapse *const synapse = a->comp.priv;
const struct counter_available *const avail = a->comp.priv;
Expand Down Expand Up @@ -281,7 +286,7 @@ static ssize_t counter_comp_u64_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
const struct counter_attribute *const a = to_counter_attribute(attr);
struct counter_device *const counter = dev_get_drvdata(dev);
struct counter_device *const counter = counter_from_dev(dev);
int err;
u64 data = 0;

Expand Down Expand Up @@ -309,7 +314,7 @@ static ssize_t counter_comp_u64_store(struct device *dev,
const char *buf, size_t len)
{
const struct counter_attribute *const a = to_counter_attribute(attr);
struct counter_device *const counter = dev_get_drvdata(dev);
struct counter_device *const counter = counter_from_dev(dev);
int err;
u64 data = 0;

Expand Down

0 comments on commit ba6354f

Please sign in to comment.