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] [thread-next>] [day] [month] [year] [list]
Message-ID: <10aeef4ddd523b85ab34327bf384119d0d4b6567.camel@perches.com>
Date: Mon, 08 Jan 2024 18:34:30 -0800
From: Joe Perches <joe@...ches.com>
To: "sandeep.cs" <sandeep.cs@...sung.com>, 'Jiri Kosina' <jikos@...nel.org>,
  'Benjamin Tissoires' <benjamin.tissoires@...hat.com>
Cc: gaudium.lee@...sung.com, ih0923.kim@...sung.com,
 suhyun_.kim@...sung.com,  jitender.s21@...sung.com, junwan.cho@...sung.com,
 linux-input@...r.kernel.org,  linux-kernel@...r.kernel.org
Subject: Re: [HID Patchsets for Samsung driver v2 2/6] HID: Samsung : Fix
 the checkpatch complain.

On Mon, 2024-01-08 at 16:14 +0530, sandeep.cs wrote:
> > On Mon, 2024-01-08 at 14:49 +0530, Sandeep C S wrote:

Generally, it's better to refactor code that checkpatch
bleats about than merely shutting up the warning.

> > For this block, I think a rewrite using memcmp would be clearer.
> > Something like: 
> Okay . Thanks for your valuable feedback. We will promptly address your
> suggestions and enhance our code accordingly.
> And also please review other patch set as well.

Another way to write the input_mapping function is
using a static const struct and a for loop like:

static int samsung_kbd_mouse_input_mapping(struct hid_device *hdev,
	struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
	unsigned long **bit, int *max)
{
	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
	unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
	static const struct {
		unsigned hid;
		__u16 map;
	} samsung_hid_key_map[] = {
		{0x183, KEY_MEDIA},
		{0x195, KEY_EMAIL},
		{0x196, KEY_CALC},
		{0x197, KEY_COMPUTER},
		{0x22b, KEY_SEARCH},
		{0x22c, KEY_WWW},
		{0x22d, KEY_BACK},
		{0x22e, KEY_FORWARD},
		{0x22f, KEY_FAVORITES},
		{0x230, KEY_REFRESH},
		{0x231, KEY_STOP},
	};
	int i;
	unsigned hid;

	if (1 != ifnum || HID_UP_CONSUMER != (usage->hid & HID_USAGE_PAGE))
		return 0;

	hid = usage->hid & HID_USAGE;

	dbg_hid("samsung wireless keyboard/mouse input mapping event [0x%x]\n",
		hid);

	for (i = 0; i < ARRAY_SIZE(samsung_hid_key_map); i++) {
		if (hid == samsung_hid_key_map[i].hid) {
			hid_map_usage_clear(hi, usage, bit, max, EV_KEY,
					    samsung_hid_key_map[i].map);
			return 1;
		}
	}

	return 0;
}


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ