Commit 2a770b49 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'hid-for-linus-2024120501' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid

Pull HID fixes from Benjamin Tissoires:

 - regression fix in suspend/resume for i2c-hid (Kenny Levinsen)

 - fix wacom driver assuming a name can not be null (WangYuli)

 - a couple of constify changes/fixes (Thomas Weißschuh)

 - a couple of selftests/hid fixes (Maximilian Heyne & Benjamin
   Tissoires)

* tag 'hid-for-linus-2024120501' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
  selftests/hid: fix kfunc inclusions with newer bpftool
  HID: bpf: drop unneeded casts discarding const
  HID: bpf: constify hid_ops
  selftests: hid: fix typo and exit code
  HID: wacom: fix when get product name maybe null pointer
  HID: i2c-hid: Revert to using power commands to wake on resume
parents 42d52acf 8d355b56
Loading
Loading
Loading
Loading
+4 −13
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
#include <linux/module.h>
#include "hid_bpf_dispatch.h"

struct hid_ops *hid_ops;
const struct hid_ops *hid_ops;
EXPORT_SYMBOL(hid_ops);

u8 *
@@ -352,7 +352,6 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz,
{
	struct hid_report_enum *report_enum;
	struct hid_report *report;
	struct hid_device *hdev;
	u32 report_len;

	/* check arguments */
@@ -371,9 +370,7 @@ __hid_bpf_hw_check_params(struct hid_bpf_ctx *ctx, __u8 *buf, size_t *buf__sz,
	if (*buf__sz < 1)
		return -EINVAL;

	hdev = (struct hid_device *)ctx->hid; /* discard const */

	report_enum = hdev->report_enum + rtype;
	report_enum = ctx->hid->report_enum + rtype;
	report = hid_ops->hid_get_report(report_enum, buf);
	if (!report)
		return -EINVAL;
@@ -402,7 +399,6 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
		   enum hid_report_type rtype, enum hid_class_request reqtype)
{
	struct hid_bpf_ctx_kern *ctx_kern;
	struct hid_device *hdev;
	size_t size = buf__sz;
	u8 *dma_data;
	int ret;
@@ -429,13 +425,11 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
		return -EINVAL;
	}

	hdev = (struct hid_device *)ctx->hid; /* discard const */

	dma_data = kmemdup(buf, size, GFP_KERNEL);
	if (!dma_data)
		return -ENOMEM;

	ret = hid_ops->hid_hw_raw_request(hdev,
	ret = hid_ops->hid_hw_raw_request(ctx->hid,
					      dma_data[0],
					      dma_data,
					      size,
@@ -464,7 +458,6 @@ __bpf_kfunc int
hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz)
{
	struct hid_bpf_ctx_kern *ctx_kern;
	struct hid_device *hdev;
	size_t size = buf__sz;
	u8 *dma_data;
	int ret;
@@ -478,13 +471,11 @@ hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz)
	if (ret)
		return ret;

	hdev = (struct hid_device *)ctx->hid; /* discard const */

	dma_data = kmemdup(buf, size, GFP_KERNEL);
	if (!dma_data)
		return -ENOMEM;

	ret = hid_ops->hid_hw_output_report(hdev, dma_data, size, (u64)(long)ctx, true);
	ret = hid_ops->hid_hw_output_report(ctx->hid, dma_data, size, (u64)(long)ctx, true);

	kfree(dma_data);
	return ret;
+1 −1
Original line number Diff line number Diff line
@@ -3064,7 +3064,7 @@ int hid_check_keys_pressed(struct hid_device *hid)
EXPORT_SYMBOL_GPL(hid_check_keys_pressed);

#ifdef CONFIG_HID_BPF
static struct hid_ops __hid_ops = {
static const struct hid_ops __hid_ops = {
	.hid_get_report = hid_get_report,
	.hid_hw_raw_request = __hid_hw_raw_request,
	.hid_hw_output_report = __hid_hw_output_report,
+12 −8
Original line number Diff line number Diff line
@@ -414,7 +414,19 @@ static int i2c_hid_set_power(struct i2c_hid *ihid, int power_state)

	i2c_hid_dbg(ihid, "%s\n", __func__);

	/*
	 * Some STM-based devices need 400µs after a rising clock edge to wake
	 * from deep sleep, in which case the first request will fail due to
	 * the address not being acknowledged. Try after a short sleep to see
	 * if the device came alive on the bus. Certain Weida Tech devices also
	 * need this.
	 */
	ret = i2c_hid_set_power_command(ihid, power_state);
	if (ret && power_state == I2C_HID_PWR_ON) {
		usleep_range(400, 500);
		ret = i2c_hid_set_power_command(ihid, I2C_HID_PWR_ON);
	}

	if (ret)
		dev_err(&ihid->client->dev,
			"failed to change power setting.\n");
@@ -976,14 +988,6 @@ static int i2c_hid_core_resume(struct i2c_hid *ihid)

	enable_irq(client->irq);

	/* Make sure the device is awake on the bus */
	ret = i2c_hid_probe_address(ihid);
	if (ret < 0) {
		dev_err(&client->dev, "nothing at address after resume: %d\n",
			ret);
		return -ENXIO;
	}

	/* On Goodix 27c6:0d42 wait extra time before device wakeup.
	 * It's not clear why but if we send wakeup too early, the device will
	 * never trigger input interrupts.
+2 −1
Original line number Diff line number Diff line
@@ -2241,6 +2241,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix)
		if (hid_is_usb(wacom->hdev)) {
			struct usb_interface *intf = to_usb_interface(wacom->hdev->dev.parent);
			struct usb_device *dev = interface_to_usbdev(intf);
			if (dev->product != NULL)
				product_name = dev->product;
		}

+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ struct hid_ops {
	const struct bus_type *bus_type;
};

extern struct hid_ops *hid_ops;
extern const struct hid_ops *hid_ops;

/**
 * struct hid_bpf_ops - A BPF struct_ops of callbacks allowing to attach HID-BPF
Loading