diff mbox

[2/2] HID: sensors: remove some unneeded checks

Message ID 20120914065346.GE11886@elgon.mountain (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Dan Carpenter Sept. 14, 2012, 6:53 a.m. UTC
"report_id" is unsigned so it's never less than zero.  These checks can
be removed without any problem.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jiri Kosina Sept. 17, 2012, 10:59 a.m. UTC | #1
On Fri, 14 Sep 2012, Dan Carpenter wrote:

> "report_id" is unsigned so it's never less than zero.  These checks can
> be removed without any problem.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Adding Jonathan to CC as well. Thanks.

> 
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index 0c93b10..22ec3c6 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -214,9 +214,6 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
>  	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
>  	int ret = 0;
>  
> -	if (report_id < 0)
> -		return -EINVAL;
> -
>  	mutex_lock(&data->mutex);
>  	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
>  	if (!report || (field_index >=  report->maxfield)) {
> @@ -241,9 +238,6 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
>  	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
>  	int ret = 0;
>  
> -	if (report_id < 0)
> -		return -EINVAL;
> -
>  	mutex_lock(&data->mutex);
>  	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
>  	if (!report || (field_index >=  report->maxfield)) {
> @@ -271,9 +265,6 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
>  	struct hid_report *report;
>  	int ret_val = 0;
>  
> -	if (report_id < 0)
> -		return -EINVAL;
> -
>  	mutex_lock(&data->mutex);
>  	memset(&data->pending, 0, sizeof(data->pending));
>  	init_completion(&data->pending.ready);
>
Pandruvada, Srinivas Sept. 17, 2012, 3:21 p.m. UTC | #2
Tested this and it works.

-----Original Message-----
From: Jiri Kosina [mailto:jkosina@suse.cz] 
Sent: Monday, September 17, 2012 4:00 AM
To: Dan Carpenter
Cc: Pandruvada, Srinivas; linux-input@vger.kernel.org; kernel-janitors@vger.kernel.org; Jonathan Cameron
Subject: Re: [patch 2/2] HID: sensors: remove some unneeded checks

On Fri, 14 Sep 2012, Dan Carpenter wrote:

> "report_id" is unsigned so it's never less than zero.  These checks 
> can be removed without any problem.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Adding Jonathan to CC as well. Thanks.

> 
> diff --git a/drivers/hid/hid-sensor-hub.c 
> b/drivers/hid/hid-sensor-hub.c index 0c93b10..22ec3c6 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -214,9 +214,6 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
>  	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
>  	int ret = 0;
>  
> -	if (report_id < 0)
> -		return -EINVAL;
> -
>  	mutex_lock(&data->mutex);
>  	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
>  	if (!report || (field_index >=  report->maxfield)) { @@ -241,9 
> +238,6 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
>  	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
>  	int ret = 0;
>  
> -	if (report_id < 0)
> -		return -EINVAL;
> -
>  	mutex_lock(&data->mutex);
>  	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
>  	if (!report || (field_index >=  report->maxfield)) { @@ -271,9 
> +265,6 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
>  	struct hid_report *report;
>  	int ret_val = 0;
>  
> -	if (report_id < 0)
> -		return -EINVAL;
> -
>  	mutex_lock(&data->mutex);
>  	memset(&data->pending, 0, sizeof(data->pending));
>  	init_completion(&data->pending.ready);
> 

--
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jonathan Cameron Sept. 18, 2012, 8:52 p.m. UTC | #3
I've add these both to the togreg branch of

git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git

Will send onwards in a few days.

> Tested this and it works.
> 
> -----Original Message-----
> From: Jiri Kosina [mailto:jkosina@suse.cz] 
> Sent: Monday, September 17, 2012 4:00 AM
> To: Dan Carpenter
> Cc: Pandruvada, Srinivas; linux-input@vger.kernel.org; kernel-janitors@vger.kernel.org; Jonathan Cameron
> Subject: Re: [patch 2/2] HID: sensors: remove some unneeded checks
> 
> On Fri, 14 Sep 2012, Dan Carpenter wrote:
> 
>> "report_id" is unsigned so it's never less than zero.  These checks 
>> can be removed without any problem.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> 
> Adding Jonathan to CC as well. Thanks.
> 
>>
>> diff --git a/drivers/hid/hid-sensor-hub.c 
>> b/drivers/hid/hid-sensor-hub.c index 0c93b10..22ec3c6 100644
>> --- a/drivers/hid/hid-sensor-hub.c
>> +++ b/drivers/hid/hid-sensor-hub.c
>> @@ -214,9 +214,6 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
>>  	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
>>  	int ret = 0;
>>  
>> -	if (report_id < 0)
>> -		return -EINVAL;
>> -
>>  	mutex_lock(&data->mutex);
>>  	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
>>  	if (!report || (field_index >=  report->maxfield)) { @@ -241,9 
>> +238,6 @@ int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
>>  	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
>>  	int ret = 0;
>>  
>> -	if (report_id < 0)
>> -		return -EINVAL;
>> -
>>  	mutex_lock(&data->mutex);
>>  	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
>>  	if (!report || (field_index >=  report->maxfield)) { @@ -271,9 
>> +265,6 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
>>  	struct hid_report *report;
>>  	int ret_val = 0;
>>  
>> -	if (report_id < 0)
>> -		return -EINVAL;
>> -
>>  	mutex_lock(&data->mutex);
>>  	memset(&data->pending, 0, sizeof(data->pending));
>>  	init_completion(&data->pending.ready);
>>
> 
> --
> Jiri Kosina
> SUSE Labs
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 0c93b10..22ec3c6 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -214,9 +214,6 @@  int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
 	int ret = 0;
 
-	if (report_id < 0)
-		return -EINVAL;
-
 	mutex_lock(&data->mutex);
 	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
 	if (!report || (field_index >=  report->maxfield)) {
@@ -241,9 +238,6 @@  int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
 	struct sensor_hub_data *data =  hid_get_drvdata(hsdev->hdev);
 	int ret = 0;
 
-	if (report_id < 0)
-		return -EINVAL;
-
 	mutex_lock(&data->mutex);
 	report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
 	if (!report || (field_index >=  report->maxfield)) {
@@ -271,9 +265,6 @@  int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
 	struct hid_report *report;
 	int ret_val = 0;
 
-	if (report_id < 0)
-		return -EINVAL;
-
 	mutex_lock(&data->mutex);
 	memset(&data->pending, 0, sizeof(data->pending));
 	init_completion(&data->pending.ready);