mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "sandeep.cs" <sandeep.cs@samsung.com>,
	'Jiri Kosina' <jikos@kernel.org>,
	'Benjamin Tissoires' <benjamin.tissoires@redhat.com>
Cc: gaudium.lee@samsung.com, ih0923.kim@samsung.com,
	suhyun_.kim@samsung.com,  jitender.s21@samsung.com,
	junwan.cho@samsung.com, linux-input@vger.kernel.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [HID Patchsets for Samsung driver v2 2/6] HID: Samsung : Fix the checkpatch complain.
Date: Mon, 08 Jan 2024 18:34:30 -0800	[thread overview]
Message-ID: <10aeef4ddd523b85ab34327bf384119d0d4b6567.camel@perches.com> (raw)
In-Reply-To: <020e01da421f$c0d20660$42761320$@samsung.com>

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;
}


  reply	other threads:[~2024-01-09  2:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20240108091950epcas5p41633efaf7b62db312982aa2f94a26db3@epcas5p4.samsung.com>
2024-01-08  9:19 ` [HID Patchsets for Samsung driver v2 0/6] HID Support for Samsung driver Sandeep C S
     [not found]   ` <CGME20240108091954epcas5p39f9ca04b57adf01a7c964593b7be87d2@epcas5p3.samsung.com>
2024-01-08  9:19     ` [HID Patchsets for Samsung driver v2 1/6] HID Samsung : Broaden device compatibility in samsung driver Sandeep C S
     [not found]   ` <CGME20240108091959epcas5p2559b779424e2fb7c7e268d1b24612b4f@epcas5p2.samsung.com>
2024-01-08  9:19     ` [HID Patchsets for Samsung driver v2 2/6] HID: Samsung : Fix the checkpatch complain Sandeep C S
2024-01-08 10:21       ` Joe Perches
2024-01-08 10:44         ` sandeep.cs
2024-01-09  2:34           ` Joe Perches [this message]
2024-01-23  9:49           ` Jiri Kosina
2024-01-23 10:04             ` sandeep.cs
     [not found]   ` <CGME20240108092004epcas5p1c7069a6ede85066817d8ce5a79da75ad@epcas5p1.samsung.com>
2024-01-08  9:19     ` [HID Patchsets for Samsung driver v2 3/6] HID: Samsung : Add Samsung wireless keyboard support Sandeep C S
     [not found]   ` <CGME20240108092009epcas5p15c5be87fa427a5c4426c55c86c5ce3bc@epcas5p1.samsung.com>
2024-01-08  9:19     ` [HID Patchsets for Samsung driver v2 4/6] HID: Samsung : Add Samsung wireless gamepad support Sandeep C S
     [not found]   ` <CGME20240108092017epcas5p24c1c263149a0a8bf3204c86925e3cfd9@epcas5p2.samsung.com>
2024-01-08  9:19     ` [HID Patchsets for Samsung driver v2 5/6] HID: Samsung : Add Samsung wireless action mouse support Sandeep C S
     [not found]   ` <CGME20240108092025epcas5p39e2ecb3b12b4fba9e41f0694f430ec1d@epcas5p3.samsung.com>
2024-01-08  9:19     ` [HID Patchsets for Samsung driver v2 6/6] HID: Samsung : Add Samsung wireless bookcover and universal keyboard support Sandeep C S

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10aeef4ddd523b85ab34327bf384119d0d4b6567.camel@perches.com \
    --to=joe@perches.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=gaudium.lee@samsung.com \
    --cc=ih0923.kim@samsung.com \
    --cc=jikos@kernel.org \
    --cc=jitender.s21@samsung.com \
    --cc=junwan.cho@samsung.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sandeep.cs@samsung.com \
    --cc=suhyun_.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®