lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Mon, 1 Dec 2014 21:36:05 +0100 (CET)
From:	Jiri Kosina <jkosina@...e.cz>
To:	Mathieu Magnaudet <mathieu.magnaudet@...il.com>
cc:	Benjamin Tissoires <benjamin.tissoires@...hat.com>,
	linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hid: export hid_report_len as an inline function in
 hid.h

On Thu, 27 Nov 2014, Mathieu Magnaudet wrote:

> in several hid drivers it is necessary to calculate the length
> of an hid_report. This patch exports the existing static function
> hid_report_len of hid-core.c as an inline function in hid.h
> 
> Signed-off-by: Mathieu Magnaudet <mathieu.magnaudet@...c.fr>

Applied, thanks.

[ ... snip ... ]
> diff --git a/include/linux/hid.h b/include/linux/hid.h
> index d585d02..06c4607 100644
> --- a/include/linux/hid.h
> +++ b/include/linux/hid.h
> @@ -1087,6 +1087,17 @@ static inline void hid_hw_wait(struct hid_device *hdev)
>  		hdev->ll_driver->wait(hdev);
>  }
>  
> +/**
> + * hid_report_len - calculate the report length
> + *
> + * @report: the report we want to know the length
> + */
> +static inline int hid_report_len(struct hid_report *report)
> +{
> +	/* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */
> +	return ((report->size - 1) >> 3) + 1 + (report->id > 0);

BTW this makes me -- being the person resposible for that ugly calculation 
-- wonder whether we shouldn't, in the name of readability, just drop the 
comment and make the code look that way instead.

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ