HID: lg: Remove unnecessary casts of void pointers
PATCH 1/4 HID: lg: Remove unnecessary casts of void pointers
Signed-off-by Axel Lin <[email protected]>
--- drivers/hid/hid-lg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hid/hid-lg.c +5 -5
@@ -108,7 +108,7 @@ static __u8 dfp_rdesc_fixed[] = {static __u8 *lg_report_fixup (struct hid_device *hdev,__u8 *rdesc,unsigned int *rsize) { -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hdev); +struct lg_drv_data *drv_data =hid_get_drvdata (hdev);if ((drv_data->quirks &LG_RDESC ) && *rsize >=90 && rdesc[83 ] ==0x26 && rdesc[84 ] ==0x8c && rdesc[85 ] ==0x02 ) {
@@ -277,7 +277,7 @@ static int lg_input_mapping(struct hid_device *hdev, struct hid_input *hi,0 ,0 ,0 ,0 ,0 ,183 ,184 ,185 ,186 ,187 ,188 ,189 ,190 ,191 ,192 ,193 ,194 ,0 ,0 ,0 }; -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hdev); +struct lg_drv_data *drv_data =hid_get_drvdata (hdev);unsigned int hid = usage->hid; if (hdev->product == USB_DEVICE_ID_LOGITECH_RECEIVER &&
@@ -318,7 +318,7 @@ static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { - struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata(hdev); + struct lg_drv_data *drv_data = hid_get_drvdata(hdev);if ((drv_data->quirks &LG_BAD_RELATIVE_KEYS ) && usage->type ==EV_KEY && (field->flags &HID_MAIN_ITEM_RELATIVE ))
@@ -334,7 +334,7 @@ static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi,static int lg_event (struct hid_device *hdev,struct hid_field *field,struct hid_usage *usage,__s32 value) { -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hdev); +struct lg_drv_data *drv_data =hid_get_drvdata (hdev);if ((drv_data->quirks &LG_INVERT_HWHEEL ) && usage->code ==REL_HWHEEL ) { input_event(field->hidinput->input, usage->type, usage->code,
@@ -415,7 +415,7 @@ err_free:static void lg_remove (struct hid_device *hdev) { -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hdev); +struct lg_drv_data *drv_data =hid_get_drvdata (hdev);if (drv_data->quirks &LG_FF4 )lg4ff_deinit (hdev);
Signature · 1 line
1.7.9.5
PATCH 2/4 HID: lg4ff: Remove unnecessary casts of void pointers
Signed-off-by Axel Lin <[email protected]>
--- drivers/hid/hid-lg4ff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/hid-lg4ff.c +2 -2
@@ -360,7 +360,7 @@ static void lg4ff_led_set_brightness(struct led_classdev *led_cdev, {struct device *dev = led_cdev->dev->parent; struct hid_device *hid = container_of(dev, struct hid_device, dev); -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hid); +struct lg_drv_data *drv_data =hid_get_drvdata (hid);struct lg4ff_device_entry *entry;int i, state =0 ;
@@ -395,7 +395,7 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde {struct device *dev = led_cdev->dev->parent; struct hid_device *hid = container_of(dev, struct hid_device, dev); -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hid); +struct lg_drv_data *drv_data =hid_get_drvdata (hid);struct lg4ff_device_entry *entry;int i, value =0 ;
Signature · 1 line
1.7.9.5
Jiri Kosina
AppliedRe: [PATCH 2/4] HID: lg4ff: Remove unnecessary casts of void pointers
Quoted 4 lines · Axel Lin
Signed-off-by Axel Lin <[email protected]>--- drivers/hid/hid-lg4ff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied, thanks.
Quoted 28 lines
drivers/hid/hid-lg4ff.c +2
-2@@ -360,7 +360,7 @@ static void lg4ff_led_set_brightness(struct led_classdev *led_cdev, {struct device *dev = led_cdev->dev->parent; struct hid_device *hid = container_of(dev, struct hid_device, dev); -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hid); +struct lg_drv_data *drv_data =hid_get_drvdata (hid);struct lg4ff_device_entry *entry;int i, state =0 ;@@ -395,7 +395,7 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde {struct device *dev = led_cdev->dev->parent; struct hid_device *hid = container_of(dev, struct hid_device, dev); -struct lg_drv_data *drv_data = (struct lg_drv_data *)hid_get_drvdata (hid); +struct lg_drv_data *drv_data =hid_get_drvdata (hid);struct lg4ff_device_entry *entry;int i, value =0 ;Signature · 1 line
1.7.9.5
Signature · 2 lines
Jiri Kosina SUSE Labs
PATCH 3/4 HID: prodikeys: Remove unnecessary casts of void pointers
In reply to Axel LinSigned-off-by Axel Lin <[email protected]>
--- drivers/hid/hid-prodikeys.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/hid/hid-prodikeys.c +9 -9
@@ -105,7 +105,7 @@ static ssize_t show_channel(struct device *dev, struct device_attribute *attr, char *buf) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);dbg_hid ("pcmidi sysfs read channel=%u\n" , pk->pm->midi_channel);
@@ -118,7 +118,7 @@ static ssize_t store_channel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);unsigned channel =0 ;
@@ -142,7 +142,7 @@ static ssize_t show_sustain(struct device *dev, struct device_attribute *attr, char *buf) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);dbg_hid ("pcmidi sysfs read sustain=%u\n" , pk->pm->midi_sustain);
@@ -155,7 +155,7 @@ static ssize_t store_sustain(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);unsigned sustain =0 ;
@@ -181,7 +181,7 @@ static ssize_t show_octave(struct device *dev, struct device_attribute *attr, char *buf) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);dbg_hid ("pcmidi sysfs read octave=%d\n" , pk->pm->midi_octave);
@@ -194,7 +194,7 @@ static ssize_t store_octave(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct hid_device *hdev = container_of(dev, struct hid_device, dev); -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);int octave =0 ;
@@ -759,7 +759,7 @@ static int pk_input_mapping(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { - struct pk_device *pk = (struct pk_device *)hid_get_drvdata(hdev); + struct pk_device *pk = hid_get_drvdata(hdev);struct pcmidi_snd *pm; pm = pk->pm;
@@ -777,7 +777,7 @@ static int pk_input_mapping(struct hid_device *hdev, struct hid_input *hi,static int pk_raw_event (struct hid_device *hdev,struct hid_report *report,u8 *data,int size) { -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);int ret =0 ;if (1 == pk->pm->ifnum) {
@@ -858,7 +858,7 @@ err_free_pk:static void pk_remove (struct hid_device *hdev) { -struct pk_device *pk = (struct pk_device *)hid_get_drvdata (hdev); +struct pk_device *pk =hid_get_drvdata (hdev);struct pcmidi_snd *pm; pm = pk->pm;
Signature · 1 line
1.7.9.5
Jiri Kosina
AppliedRe: [PATCH 3/4] HID: prodikeys: Remove unnecessary casts of void pointers
Quoted 4 lines · Axel Lin
Signed-off-by Axel Lin <[email protected]>--- drivers/hid/hid-prodikeys.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
Applied, thanks Axel.
Signature · 2 lines
Jiri Kosina SUSE Labs
PATCH 4/4 HID: lenovo-tpkbd: Remove unnecessary casts of void pointers
In reply to Axel Lincontainer_of() never returns NULL, thus also remove the NULL checking for it.
Signed-off-by Axel Lin <[email protected]>
--- drivers/hid/hid-lenovo-tpkbd.c | 147 +++++++++------------------------------- 1 file changed, 33 insertions(+), 114 deletions(-)
drivers/hid/hid-lenovo-tpkbd.c +33 -114
@@ -56,9 +56,8 @@ static int tpkbd_input_mapping(struct hid_device *hdev,static int tpkbd_features_set (struct hid_device *hdev) {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->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,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )
@@ -119,14 +106,8 @@ static ssize_t pointer_dragging_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);return snprintf (buf,PAGE_SIZE ,"%u\n" , data_pointer->dragging); }
@@ -136,16 +117,10 @@ static ssize_t pointer_dragging_store(struct device *dev, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )
@@ -161,14 +136,8 @@ static ssize_t pointer_release_to_select_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )
@@ -203,14 +166,8 @@ static ssize_t pointer_select_right_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )
@@ -245,14 +196,8 @@ static ssize_t pointer_sensitivity_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);return snprintf (buf,PAGE_SIZE ,"%u\n" , data_pointer->sensitivity);
@@ -263,16 +208,10 @@ static ssize_t pointer_sensitivity_store(struct device *dev, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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 )return -EINVAL ;
@@ -286,14 +225,10 @@ static ssize_t pointer_press_speed_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +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); + data_pointer =hid_get_drvdata (hdev);return snprintf (buf,PAGE_SIZE ,"%u\n" , data_pointer->press_speed);
@@ -304,16 +239,10 @@ static ssize_t pointer_press_speed_store(struct device *dev, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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 )return -EINVAL ;
@@ -370,15 +299,11 @@ static const struct attribute_group tpkbd_attr_group_pointer = {static enum led_brightness tpkbd_led_brightness_get (struct led_classdev *led_cdev) { -struct device *dev; -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; +struct device *dev = led_cdev->dev->parent; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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) led_nr =1 ;
@@ -390,16 +315,12 @@ static enum led_brightness tpkbd_led_brightness_get(static void tpkbd_led_brightness_set (struct led_classdev *led_cdev,enum led_brightness value) { -struct device *dev; -struct hid_device *hdev; +struct device *dev = led_cdev->dev->parent; + 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 tpkbd_data_pointer *data_pointer;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) led_nr =1 ;
@@ -508,13 +429,11 @@ err_free: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, &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_mute);
Signature · 1 line
1.7.9.5
Re: [PATCH 4/4] HID: lenovo-tpkbd: Remove unnecessary casts of void pointers
Quoted 3 lines · Axel Lin
container_of()never returns NULL, thus also remove the NULL checking for it.Signed-off-by Axel Lin <[email protected]>
Makes sense, applied, thanks.
Quoted 295 lines
--- drivers/hid/hid-lenovo-tpkbd.c | 147 +++++++++------------------------------- 1 file changed, 33 insertions(+), 114 deletions(-)drivers/hid/hid-lenovo-tpkbd.c +33
-114@@ -56,9 +56,8 @@ static int tpkbd_input_mapping(struct hid_device *hdev,static int tpkbd_features_set (struct hid_device *hdev) {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->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,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )@@ -119,14 +106,8 @@ static ssize_t pointer_dragging_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);return snprintf (buf,PAGE_SIZE ,"%u\n" , data_pointer->dragging); }@@ -136,16 +117,10 @@ static ssize_t pointer_dragging_store(struct device *dev, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )@@ -161,14 +136,8 @@ static ssize_t pointer_release_to_select_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )@@ -203,14 +166,8 @@ static ssize_t pointer_select_right_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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))return -EINVAL ;if (value <0 || value >1 )@@ -245,14 +196,8 @@ static ssize_t pointer_sensitivity_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; - - hdev = container_of(dev, struct hid_device, dev); -if (hdev ==NULL ) -return -ENODEV ; - - data_pointer = (struct tpkbd_data_pointer *)hid_get_drvdata (hdev); + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);return snprintf (buf,PAGE_SIZE ,"%u\n" , data_pointer->sensitivity);@@ -263,16 +208,10 @@ static ssize_t pointer_sensitivity_store(struct device *dev, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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 )return -EINVAL ;@@ -286,14 +225,10 @@ static ssize_t pointer_press_speed_show(struct device *dev,struct device_attribute *attr, char *buf) { - struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +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); + data_pointer =hid_get_drvdata (hdev);return snprintf (buf,PAGE_SIZE ,"%u\n" , data_pointer->press_speed);@@ -304,16 +239,10 @@ static ssize_t pointer_press_speed_store(struct device *dev, const char *buf, size_t count) { -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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 )return -EINVAL ;@@ -370,15 +299,11 @@ static const struct attribute_group tpkbd_attr_group_pointer = {static enum led_brightness tpkbd_led_brightness_get (struct led_classdev *led_cdev) { -struct device *dev; -struct hid_device *hdev; -struct tpkbd_data_pointer *data_pointer; +struct device *dev = led_cdev->dev->parent; + struct hid_device *hdev = container_of(dev, struct hid_device, dev); +struct tpkbd_data_pointer *data_pointer =hid_get_drvdata (hdev);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) led_nr =1 ;@@ -390,16 +315,12 @@ static enum led_brightness tpkbd_led_brightness_get(static void tpkbd_led_brightness_set (struct led_classdev *led_cdev,enum led_brightness value) { -struct device *dev; -struct hid_device *hdev; +struct device *dev = led_cdev->dev->parent; + 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 tpkbd_data_pointer *data_pointer;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) led_nr =1 ;@@ -508,13 +429,11 @@ err_free: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, &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_mute);Signature · 1 line
1.7.9.5
Signature · 2 lines
Jiri Kosina SUSE Labs
Jiri Kosina
AppliedQuoted 4 lines · Axel Lin
Signed-off-by Axel Lin <[email protected]>--- drivers/hid/hid-lg.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Applied, thanks.
Signature · 2 lines
Jiri Kosina SUSE Labs