提交 832fbeae 编写于 作者: A Axel Lin 提交者: Jiri Kosina

HID: lenovo-tpkbd: Remove unnecessary casts of void pointers

container_of() never returns NULL, thus also remove the NULL checking for it.
Signed-off-by: NAxel Lin <axel.lin@gmail.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 372d297b
...@@ -56,9 +56,8 @@ static int tpkbd_input_mapping(struct hid_device *hdev, ...@@ -56,9 +56,8 @@ static int tpkbd_input_mapping(struct hid_device *hdev,
static int tpkbd_features_set(struct hid_device *hdev) static int tpkbd_features_set(struct hid_device *hdev)
{ {
struct hid_report *report; struct hid_report *report;
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4]; report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[4];
report->field[0]->value[0] = data_pointer->press_to_select ? 0x01 : 0x02; report->field[0]->value[0] = data_pointer->press_to_select ? 0x01 : 0x02;
...@@ -77,14 +76,8 @@ static ssize_t pointer_press_to_select_show(struct device *dev, ...@@ -77,14 +76,8 @@ static ssize_t pointer_press_to_select_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->press_to_select);
} }
...@@ -94,16 +87,10 @@ static ssize_t pointer_press_to_select_store(struct device *dev, ...@@ -94,16 +87,10 @@ static ssize_t pointer_press_to_select_store(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
int value; int value;
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (kstrtoint(buf, 10, &value)) if (kstrtoint(buf, 10, &value))
return -EINVAL; return -EINVAL;
if (value < 0 || value > 1) if (value < 0 || value > 1)
...@@ -119,14 +106,8 @@ static ssize_t pointer_dragging_show(struct device *dev, ...@@ -119,14 +106,8 @@ static ssize_t pointer_dragging_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->dragging);
} }
...@@ -136,16 +117,10 @@ static ssize_t pointer_dragging_store(struct device *dev, ...@@ -136,16 +117,10 @@ static ssize_t pointer_dragging_store(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
int value; int value;
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (kstrtoint(buf, 10, &value)) if (kstrtoint(buf, 10, &value))
return -EINVAL; return -EINVAL;
if (value < 0 || value > 1) if (value < 0 || value > 1)
...@@ -161,14 +136,8 @@ static ssize_t pointer_release_to_select_show(struct device *dev, ...@@ -161,14 +136,8 @@ static ssize_t pointer_release_to_select_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->release_to_select);
} }
...@@ -178,16 +147,10 @@ static ssize_t pointer_release_to_select_store(struct device *dev, ...@@ -178,16 +147,10 @@ static ssize_t pointer_release_to_select_store(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
int value; int value;
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (kstrtoint(buf, 10, &value)) if (kstrtoint(buf, 10, &value))
return -EINVAL; return -EINVAL;
if (value < 0 || value > 1) if (value < 0 || value > 1)
...@@ -203,14 +166,8 @@ static ssize_t pointer_select_right_show(struct device *dev, ...@@ -203,14 +166,8 @@ static ssize_t pointer_select_right_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right); return snprintf(buf, PAGE_SIZE, "%u\n", data_pointer->select_right);
} }
...@@ -220,16 +177,10 @@ static ssize_t pointer_select_right_store(struct device *dev, ...@@ -220,16 +177,10 @@ static ssize_t pointer_select_right_store(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
int value; int value;
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (kstrtoint(buf, 10, &value)) if (kstrtoint(buf, 10, &value))
return -EINVAL; return -EINVAL;
if (value < 0 || value > 1) if (value < 0 || value > 1)
...@@ -245,14 +196,8 @@ static ssize_t pointer_sensitivity_show(struct device *dev, ...@@ -245,14 +196,8 @@ static ssize_t pointer_sensitivity_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", return snprintf(buf, PAGE_SIZE, "%u\n",
data_pointer->sensitivity); data_pointer->sensitivity);
...@@ -263,16 +208,10 @@ static ssize_t pointer_sensitivity_store(struct device *dev, ...@@ -263,16 +208,10 @@ static ssize_t pointer_sensitivity_store(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
int value; int value;
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (kstrtoint(buf, 10, &value) || value < 1 || value > 255) if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
return -EINVAL; return -EINVAL;
...@@ -286,14 +225,10 @@ static ssize_t pointer_press_speed_show(struct device *dev, ...@@ -286,14 +225,10 @@ static ssize_t pointer_press_speed_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
hdev = container_of(dev, struct hid_device, dev); data_pointer = hid_get_drvdata(hdev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
return snprintf(buf, PAGE_SIZE, "%u\n", return snprintf(buf, PAGE_SIZE, "%u\n",
data_pointer->press_speed); data_pointer->press_speed);
...@@ -304,16 +239,10 @@ static ssize_t pointer_press_speed_store(struct device *dev, ...@@ -304,16 +239,10 @@ static ssize_t pointer_press_speed_store(struct device *dev,
const char *buf, const char *buf,
size_t count) size_t count)
{ {
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
int value; int value;
hdev = container_of(dev, struct hid_device, dev);
if (hdev == NULL)
return -ENODEV;
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (kstrtoint(buf, 10, &value) || value < 1 || value > 255) if (kstrtoint(buf, 10, &value) || value < 1 || value > 255)
return -EINVAL; return -EINVAL;
...@@ -370,15 +299,11 @@ static const struct attribute_group tpkbd_attr_group_pointer = { ...@@ -370,15 +299,11 @@ static const struct attribute_group tpkbd_attr_group_pointer = {
static enum led_brightness tpkbd_led_brightness_get( static enum led_brightness tpkbd_led_brightness_get(
struct led_classdev *led_cdev) struct led_classdev *led_cdev)
{ {
struct device *dev; struct device *dev = led_cdev->dev->parent;
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
int led_nr = 0; int led_nr = 0;
dev = led_cdev->dev->parent;
hdev = container_of(dev, struct hid_device, dev);
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (led_cdev == &data_pointer->led_micmute) if (led_cdev == &data_pointer->led_micmute)
led_nr = 1; led_nr = 1;
...@@ -390,16 +315,12 @@ static enum led_brightness tpkbd_led_brightness_get( ...@@ -390,16 +315,12 @@ static enum led_brightness tpkbd_led_brightness_get(
static void tpkbd_led_brightness_set(struct led_classdev *led_cdev, static void tpkbd_led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value) enum led_brightness value)
{ {
struct device *dev; struct device *dev = led_cdev->dev->parent;
struct hid_device *hdev; struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
struct hid_report *report; struct hid_report *report;
struct tpkbd_data_pointer *data_pointer;
int led_nr = 0; int led_nr = 0;
dev = led_cdev->dev->parent;
hdev = container_of(dev, struct hid_device, dev);
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
if (led_cdev == &data_pointer->led_micmute) if (led_cdev == &data_pointer->led_micmute)
led_nr = 1; led_nr = 1;
...@@ -508,13 +429,11 @@ static int tpkbd_probe(struct hid_device *hdev, ...@@ -508,13 +429,11 @@ static int tpkbd_probe(struct hid_device *hdev,
static void tpkbd_remove_tp(struct hid_device *hdev) static void tpkbd_remove_tp(struct hid_device *hdev)
{ {
struct tpkbd_data_pointer *data_pointer; struct tpkbd_data_pointer *data_pointer = hid_get_drvdata(hdev);
sysfs_remove_group(&hdev->dev.kobj, sysfs_remove_group(&hdev->dev.kobj,
&tpkbd_attr_group_pointer); &tpkbd_attr_group_pointer);
data_pointer = (struct tpkbd_data_pointer *) hid_get_drvdata(hdev);
led_classdev_unregister(&data_pointer->led_micmute); led_classdev_unregister(&data_pointer->led_micmute);
led_classdev_unregister(&data_pointer->led_mute); led_classdev_unregister(&data_pointer->led_mute);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册