From patchwork Mon Jul 3 18:52:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E000C30654 for ; Mon, 3 Jul 2023 18:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbjGCSwa (ORCPT ); Mon, 3 Jul 2023 14:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229989AbjGCSw2 (ORCPT ); Mon, 3 Jul 2023 14:52:28 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1465E72; Mon, 3 Jul 2023 11:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410347; x=1719946347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0qX8wJqCVwS6J5mYlzsfBNDUlm1C8MXGFzfdUeV0hJg=; b=KJLvrjEU7DE5rusmQtdVhwzMqMwbsTs0TK+ZnOwxBWGaxdu7AYqLbbll WkPjkomkC3IkuIgFaCCZmXAkCi1DXaR8ggJtnjuugOTSRl0JFDm76IaD5 C/lBwftO2apDLJEI1EKegusuYF5+ws49hxqOlJhN/cXh2h7gc2DqYY/Ce T0Z1Yf/Y82lPvjDE21ZOC5e2fgXyMPlX9ndUc0l8uxuTVtyUPlxr73Cba 15B/44Y780fK8wpz/Us2SXk/1tLJUClwXGXNyZIQ6gmQtgtenXztbxAjY 86ypeVhdZkmbL/f15wJ6EimtVUzLUV9W/BBS4B5OsvNGR7WxnEN0+ai44 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="362986956" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="362986956" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="721860810" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="721860810" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 03 Jul 2023 11:52:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 2803013C; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 01/12] lib/string_choices: Add str_write_read() helper Date: Mon, 3 Jul 2023 21:52:11 +0300 Message-Id: <20230703185222.50554-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add an inversed variant of str_read_write(), i.e. str_write_read(). Signed-off-by: Andy Shevchenko --- include/linux/string_choices.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h index 48120222b9b2..3c1091941eb8 100644 --- a/include/linux/string_choices.h +++ b/include/linux/string_choices.h @@ -30,6 +30,7 @@ static inline const char *str_read_write(bool v) { return v ? "read" : "write"; } +#define str_write_read(v) str_read_write(!(v)) static inline const char *str_on_off(bool v) { From patchwork Mon Jul 3 18:52:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E409FC001B3 for ; Mon, 3 Jul 2023 18:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231289AbjGCSwa (ORCPT ); Mon, 3 Jul 2023 14:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230200AbjGCSw2 (ORCPT ); Mon, 3 Jul 2023 14:52:28 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1CABE73; Mon, 3 Jul 2023 11:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410347; x=1719946347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z7YG+rldaGnIVAOwR04bpca61wVV/LIPBDGMSpPP1uE=; b=kQdjEqQORu9F5FZGwszkvMck9/fJHKZYaJcwb9dKq+bTWEPkTWr8SMHj SWs2N5jxGj0FlYMLBiDq8oHDabcrhNFNWptcBkit6LfObBfYST+rspO5n LCqckO75JTZJrbYoFrEpykW+albNmeQHWFTXohY29WPxmxAZwL9x4hh4p e5IdLLyAFzpfzQuD1BkWdYrSyIdibU/KW0KjudECHDcx/cDaFb+Up8Bjo WXxjPTdtBn2F25bLKT115oxuwpHYexbBWg2NylULbokzqjldwZwqGTCyg +Lb7KBZf3S3akd9xw3iVBmvUmgjXhWdNhwhLBL2b7mOFi3Uu8sdE6M3ZE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="347736200" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="347736200" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="842743323" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="842743323" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga004.jf.intel.com with ESMTP; 03 Jul 2023 11:52:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 337E0177; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 02/12] HID: cp2112: Use str_write_read() and str_read_write() Date: Mon, 3 Jul 2023 21:52:12 +0300 Message-Id: <20230703185222.50554-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use str_write_read() and str_read_write() from string_choices.h. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 27cadadda7c9..37ccf4714ad1 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "hid-ids.h" @@ -532,15 +533,13 @@ static int cp2112_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, hid_dbg(hdev, "I2C %d messages\n", num); if (num == 1) { + hid_dbg(hdev, "I2C %s %#04x len %d\n", + str_read_write(msgs->flags & I2C_M_RD), msgs->addr, msgs->len); if (msgs->flags & I2C_M_RD) { - hid_dbg(hdev, "I2C read %#04x len %d\n", - msgs->addr, msgs->len); read_length = msgs->len; read_buf = msgs->buf; count = cp2112_read_req(buf, msgs->addr, msgs->len); } else { - hid_dbg(hdev, "I2C write %#04x len %d\n", - msgs->addr, msgs->len); count = cp2112_i2c_write_req(buf, msgs->addr, msgs->buf, msgs->len); } @@ -648,7 +647,7 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr, int ret; hid_dbg(hdev, "%s addr 0x%x flags 0x%x cmd 0x%x size %d\n", - read_write == I2C_SMBUS_WRITE ? "write" : "read", + str_write_read(read_write == I2C_SMBUS_WRITE), addr, flags, command, size); switch (size) { From patchwork Mon Jul 3 18:52:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C7EEC001DD for ; Mon, 3 Jul 2023 18:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231299AbjGCSwc (ORCPT ); Mon, 3 Jul 2023 14:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbjGCSw3 (ORCPT ); Mon, 3 Jul 2023 14:52:29 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E22B7E76; Mon, 3 Jul 2023 11:52:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410347; x=1719946347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=U7xZnxo000Bh+G3CFWHwe0fIvv2SjEV0r+jJ4dVpi6k=; b=bTdK96CiPn+H/CtK0ouYngV++CwKeVhc6dfbIUD7PAyyisTxOOH9nywL GzNAoSu673XfWI6NMMPCtQYTYBUyXKvWiyoWtTVV5m4FnlgQLCDwMqrRX Hja6qbGGbD7nP/rjzj5cIi/gQZhSSYThKbr+tRiLCfcLLi79ljJv49Hck M90xV5UywJLf0Or8XjeaqdzIlwwXG4SZUMyybjZ/QkOPNwR1ZKaM7K8rt JQiAmMib1r6kW766l0WdABs8Ov94wAMfZ4smxGFBWMrUrQ86QWD/cOlfl cDnMbQfeCQ3+G3969PE+Q3HRKBJ2OHY9Jq6gmIABUk+yBGk75NRoRnjpm w==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="362986963" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="362986963" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="721860809" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="721860809" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 03 Jul 2023 11:52:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 44AD517C; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 03/12] HID: cp2112: Make irq_chip immutable Date: Mon, 3 Jul 2023 21:52:13 +0300 Message-Id: <20230703185222.50554-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Since recently, the kernel is nagging about mutable irq_chips: "not an immutable chip, please consider fixing it!" Drop the unneeded copy, flag it as IRQCHIP_IMMUTABLE, add the new helper functions and call the appropriate gpiolib functions. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 37ccf4714ad1..51399b231d36 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -164,7 +164,6 @@ struct cp2112_device { atomic_t read_avail; atomic_t xfer_avail; struct gpio_chip gc; - struct irq_chip irq; u8 *in_out_buffer; struct mutex lock; @@ -1079,16 +1078,20 @@ static void cp2112_gpio_irq_mask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct cp2112_device *dev = gpiochip_get_data(gc); + irq_hw_number_t hwirq = irqd_to_hwirq(d); - __clear_bit(d->hwirq, &dev->irq_mask); + __clear_bit(hwirq, &dev->irq_mask); + gpiochip_disable_irq(gc, hwirq); } static void cp2112_gpio_irq_unmask(struct irq_data *d) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct cp2112_device *dev = gpiochip_get_data(gc); + irq_hw_number_t hwirq = irqd_to_hwirq(d); - __set_bit(d->hwirq, &dev->irq_mask); + gpiochip_enable_irq(gc, hwirq); + __set_bit(hwirq, &dev->irq_mask); } static void cp2112_gpio_poll_callback(struct work_struct *work) @@ -1174,6 +1177,7 @@ static void cp2112_gpio_irq_shutdown(struct irq_data *d) struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct cp2112_device *dev = gpiochip_get_data(gc); + cp2112_gpio_irq_mask(d); cancel_delayed_work_sync(&dev->gpio_poll_worker); } @@ -1227,6 +1231,18 @@ static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev, return ret; } +static const struct irq_chip cp2112_gpio_irqchip = { + .name = "cp2112-gpio", + .irq_startup = cp2112_gpio_irq_startup, + .irq_shutdown = cp2112_gpio_irq_shutdown, + .irq_ack = cp2112_gpio_irq_ack, + .irq_mask = cp2112_gpio_irq_mask, + .irq_unmask = cp2112_gpio_irq_unmask, + .irq_set_type = cp2112_gpio_irq_type, + .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, +}; + static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) { struct cp2112_device *dev; @@ -1336,17 +1352,8 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.can_sleep = 1; dev->gc.parent = &hdev->dev; - dev->irq.name = "cp2112-gpio"; - dev->irq.irq_startup = cp2112_gpio_irq_startup; - dev->irq.irq_shutdown = cp2112_gpio_irq_shutdown; - dev->irq.irq_ack = cp2112_gpio_irq_ack; - dev->irq.irq_mask = cp2112_gpio_irq_mask; - dev->irq.irq_unmask = cp2112_gpio_irq_unmask; - dev->irq.irq_set_type = cp2112_gpio_irq_type; - dev->irq.flags = IRQCHIP_MASK_ON_SUSPEND; - girq = &dev->gc.irq; - girq->chip = &dev->irq; + gpio_irq_chip_set_chip(girq, &cp2112_gpio_irqchip); /* The event comes from the outside so no parent handler */ girq->parent_handler = NULL; girq->num_parents = 0; From patchwork Mon Jul 3 18:52:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85BC2C30657 for ; Mon, 3 Jul 2023 18:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231221AbjGCSw3 (ORCPT ); Mon, 3 Jul 2023 14:52:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbjGCSw2 (ORCPT ); Mon, 3 Jul 2023 14:52:28 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65B4EAF; Mon, 3 Jul 2023 11:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410346; x=1719946346; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vglDNwRcSKOGrj0IrUTDI9q4BegirR6oTWfUcwYB95I=; b=hvhHGQ6pBcLzrfrojWdTfuTNXb3IE4OaRkARPiR4eTLUftqkbUUqF2ZO dNOe1qg4X5L1RXZxIJjIBxX92fp+02hcGJWWhULRyHsNwCwY92oxiVrEx ZCLKr24w9MwPUAKyhvm1OrkNZpKUx8vpS5wLDNjMY/ZxOmXD/OkSILUWC hSI1QyDGa9znvuS98TkFwt99bwsN72McFNSz2QrKNlnvI+CNwrA6SQyGN bjH1B3DcOSAfM5s114qJSX3y7fYK46CpyhjQ057Pk0FRUCUFxIWe37BRS 3nU56ZGlym+NtnfzMFWrqClm0f7G69RFfku+VkezB93WkflteSFvk7gWc A==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="362986960" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="362986960" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="721860811" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="721860811" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 03 Jul 2023 11:52:24 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 4B284178; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 04/12] HID: cp2112: Switch to for_each_set_bit() to simplify the code Date: Mon, 3 Jul 2023 21:52:14 +0300 Message-Id: <20230703185222.50554-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org It's cleaner to use for_each_set_bit() than open coding it. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 51399b231d36..fb4548feb0c8 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -16,6 +16,7 @@ * https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf */ +#include #include #include #include @@ -1100,7 +1101,6 @@ static void cp2112_gpio_poll_callback(struct work_struct *work) gpio_poll_worker.work); struct irq_data *d; u8 gpio_mask; - u8 virqs = (u8)dev->irq_mask; u32 irq_type; int irq, virq, ret; @@ -1111,11 +1111,7 @@ static void cp2112_gpio_poll_callback(struct work_struct *work) goto exit; gpio_mask = ret; - - while (virqs) { - virq = ffs(virqs) - 1; - virqs &= ~BIT(virq); - + for_each_set_bit(virq, &dev->irq_mask, 8) { if (!dev->gc.to_irq) break; From patchwork Mon Jul 3 18:52:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C18AC3065A for ; Mon, 3 Jul 2023 18:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231296AbjGCSwb (ORCPT ); Mon, 3 Jul 2023 14:52:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbjGCSw3 (ORCPT ); Mon, 3 Jul 2023 14:52:29 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A01BAF; Mon, 3 Jul 2023 11:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410349; x=1719946349; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=afc07R7Fx+NGuUmDJNCCGkFgs3O6oULmTGVDhDPMWbQ=; b=bzzqVpwjjiTMD1+uxU2LXoO3DKd/VKT1zqAUTOFvlP2RGYJegndjPZ+0 8ShCRDnfDFWK63OxPC66DDE0gNP2U9Lh9oSMOosfM/vhSPSooDotmPetn t93qMZtSyzj4swrUbxTrcWcuCHLOnRK+n37UhYS4nHgRxqknCe8UPhPcu 0v2TzWn4utaD7uEteRRDPVnqQPAASeujm9FWEoUGwgKgKBZcvE8MHktJU pm0qUMjU2sYgrPAN5tZ+p3GnkVpATrBfwEUAFOTSD1QQztccAF+0G83v9 oO4XaJBTGpwVYkwEcziM+5yXqqxXAKOMbish9IjR58VOjAtQYc6EE6A+B w==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="362986966" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="362986966" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="721860813" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="721860813" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 03 Jul 2023 11:52:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 631041D9; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 05/12] HID: cp2112: Don't call ->to_irq() explicitly Date: Mon, 3 Jul 2023 21:52:15 +0300 Message-Id: <20230703185222.50554-6-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org GPIO library guarantees that ->to_irq() is always exists. Moreover, it tending to become a nische thingy and has to not be used in ordinary drivers. Hence, replace that by irq_find_mapping(). Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index fb4548feb0c8..15b626359281 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -1112,10 +1112,9 @@ static void cp2112_gpio_poll_callback(struct work_struct *work) gpio_mask = ret; for_each_set_bit(virq, &dev->irq_mask, 8) { - if (!dev->gc.to_irq) - break; - - irq = dev->gc.to_irq(&dev->gc, virq); + irq = irq_find_mapping(dev->gc.irq.domain, virq); + if (!irq) + continue; d = irq_get_irq_data(irq); if (!d) From patchwork Mon Jul 3 18:52:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B64AC001B3 for ; Mon, 3 Jul 2023 18:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231309AbjGCSwg (ORCPT ); Mon, 3 Jul 2023 14:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231302AbjGCSwc (ORCPT ); Mon, 3 Jul 2023 14:52:32 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DE16E64; Mon, 3 Jul 2023 11:52:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410351; x=1719946351; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m3oT3A2TkcRcs3tLyPA7LqOUifp3itwdNBboGdNimiQ=; b=ROspkP4EJUVMRRMfWVfx0z6phDsXwlENCBMxCjjZtjvtu2UROuwo0EG/ DqzYG3ZURn9LL82cvm3dZhFOLCvNrIJiZ/q8EPda2rrAOallb/Sx0LP/7 vBTaXG1ymO9hreE3Z5DbnvwNcCesXkQYwSSVLFMrLhhxfIpOHjTyXLxxI mbyLyE9UyCXn5rWbtP1w6gV4Dr/yZxIquKKesWdV+WQ/diUWv7642Pf60 KQtx5ihtO3ooLc1Rbm3sBbFfDJnYYKAXyIBOFFOOg62SURuletWr1CDn+ 51vXRZsYTJKa4a64+l2JjCFuRlJ4udGiCrjDKKA0RNyLtZImyV08RNMYf A==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="449322734" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449322734" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="831912483" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="831912483" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2023 11:52:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6911F1C7; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 06/12] HID: cp2112: Remove dead code Date: Mon, 3 Jul 2023 21:52:16 +0300 Message-Id: <20230703185222.50554-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Remove cp2112_allocate_irq() and counterparts that seems to be a dead code from day 1. In case somebody needs it, it can be retrieved from Git index. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 54 ---------------------------------------- 1 file changed, 54 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 15b626359281..45cd0d2fd3fd 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -17,8 +17,6 @@ */ #include -#include -#include #include #include #include @@ -168,7 +166,6 @@ struct cp2112_device { u8 *in_out_buffer; struct mutex lock; - struct gpio_desc *desc[8]; bool gpio_poll; struct delayed_work gpio_poll_worker; unsigned long irq_mask; @@ -1181,51 +1178,6 @@ static int cp2112_gpio_irq_type(struct irq_data *d, unsigned int type) return 0; } -static int __maybe_unused cp2112_allocate_irq(struct cp2112_device *dev, - int pin) -{ - int ret; - - if (dev->desc[pin]) - return -EINVAL; - - dev->desc[pin] = gpiochip_request_own_desc(&dev->gc, pin, - "HID/I2C:Event", - GPIO_ACTIVE_HIGH, - GPIOD_IN); - if (IS_ERR(dev->desc[pin])) { - dev_err(dev->gc.parent, "Failed to request GPIO\n"); - return PTR_ERR(dev->desc[pin]); - } - - ret = cp2112_gpio_direction_input(&dev->gc, pin); - if (ret < 0) { - dev_err(dev->gc.parent, "Failed to set GPIO to input dir\n"); - goto err_desc; - } - - ret = gpiochip_lock_as_irq(&dev->gc, pin); - if (ret) { - dev_err(dev->gc.parent, "Failed to lock GPIO as interrupt\n"); - goto err_desc; - } - - ret = gpiod_to_irq(dev->desc[pin]); - if (ret < 0) { - dev_err(dev->gc.parent, "Failed to translate GPIO to IRQ\n"); - goto err_lock; - } - - return ret; - -err_lock: - gpiochip_unlock_as_irq(&dev->gc, pin); -err_desc: - gpiochip_free_own_desc(dev->desc[pin]); - dev->desc[pin] = NULL; - return ret; -} - static const struct irq_chip cp2112_gpio_irqchip = { .name = "cp2112-gpio", .irq_startup = cp2112_gpio_irq_startup, @@ -1390,7 +1342,6 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) static void cp2112_remove(struct hid_device *hdev) { struct cp2112_device *dev = hid_get_drvdata(hdev); - int i; sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group); i2c_del_adapter(&dev->adap); @@ -1400,11 +1351,6 @@ static void cp2112_remove(struct hid_device *hdev) cancel_delayed_work_sync(&dev->gpio_poll_worker); } - for (i = 0; i < ARRAY_SIZE(dev->desc); i++) { - gpiochip_unlock_as_irq(&dev->gc, i); - gpiochip_free_own_desc(dev->desc[i]); - } - gpiochip_remove(&dev->gc); /* i2c_del_adapter has finished removing all i2c devices from our * adapter. Well behaved devices should no longer call our cp2112_xfer From patchwork Mon Jul 3 18:52:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEA81C001DD for ; Mon, 3 Jul 2023 18:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231298AbjGCSwg (ORCPT ); Mon, 3 Jul 2023 14:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231319AbjGCSwd (ORCPT ); Mon, 3 Jul 2023 14:52:33 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C11E71; Mon, 3 Jul 2023 11:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410352; x=1719946352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6yEDgvxJlryYWI7k71QyO6QRP75T9Vue+ghIMACgdzE=; b=LZJRBeTgQ0RkPPIRnxdS/0G7zd2amHq7GfSWGahuitTFSRdLJat6C6T2 1piknSPBttTqIhs1tncusrYQF9ntGQmMlQtZla99XDvjxWEmOdyrq71FM cphn99f9NvOiZSx0GJ8xkGJ/97gFxNN9eqzfJaFce1ruSJCJxFqI5JkC6 tLlIT1/px54QS7llzstL+iqt5j6abcNrWHhxpY5ai4HOq6nIV+m9vxpUm 6xgb1mSrPyt9+eOlPT8e5cdpS/m5l7wnZDmgTOOP+aitUL+8bGn6LaNiv 4rj6AFR+f+7ZU6HEIe/98SkTgV+iubZm/WoZ8/upa3WigZnqoNitULpKq g==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="449322737" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449322737" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="831912486" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="831912486" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2023 11:52:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 7902C5FC; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 07/12] HID: cp2112: Define maximum GPIO constant and use it Date: Mon, 3 Jul 2023 21:52:17 +0300 Message-Id: <20230703185222.50554-8-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Define maximum GPIO constant and use it in the driver. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 45cd0d2fd3fd..c8c59d70500e 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -31,6 +31,7 @@ #define CP2112_GPIO_CONFIG_LENGTH 5 #define CP2112_GPIO_GET_LENGTH 2 #define CP2112_GPIO_SET_LENGTH 3 +#define CP2112_GPIO_MAX_GPIO 8 enum { CP2112_GPIO_CONFIG = 0x02, @@ -1108,7 +1109,7 @@ static void cp2112_gpio_poll_callback(struct work_struct *work) goto exit; gpio_mask = ret; - for_each_set_bit(virq, &dev->irq_mask, 8) { + for_each_set_bit(virq, &dev->irq_mask, CP2112_GPIO_MAX_GPIO) { irq = irq_find_mapping(dev->gc.irq.domain, virq); if (!irq) continue; @@ -1295,7 +1296,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.set = cp2112_gpio_set; dev->gc.get = cp2112_gpio_get; dev->gc.base = -1; - dev->gc.ngpio = 8; + dev->gc.ngpio = CP2112_GPIO_MAX_GPIO; dev->gc.can_sleep = 1; dev->gc.parent = &hdev->dev; From patchwork Mon Jul 3 18:52:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD560C001DD for ; Mon, 3 Jul 2023 18:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbjGCSwn (ORCPT ); Mon, 3 Jul 2023 14:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231341AbjGCSwf (ORCPT ); Mon, 3 Jul 2023 14:52:35 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAA2FE7C; Mon, 3 Jul 2023 11:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410353; x=1719946353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LCgdVKzpcSaOUGJnyo5Kogm8rdwSx8t88vdpkdS1kM4=; b=dtjfJBOBx6zqL1e/DIRNxWjFlJpFgl/Gi4Hsfi0WysZWokYHGqTZuo2o 4zohCAAYJbPzldziHBB8VUVece5TMCaOHSBSvFuRfVPbrfcEdDP5g6+14 wv1WbdyK8ltBJIKAUW93d+HFJWgcLiLqp9fKAeTRNeYoHz6xCeMUgyTSj qikZ4+0jLOcKzuoVGBL3xZiBpgZeG+qsp9yg3oIS3RCe86AQuMzAflVx4 AvuUUZxqsaUH+yxnbYu+dkOUQnEidyjmgQYfG8kcgCQ+g2X4GYnhA//AQ EwOCJx+9nHp2zBp1XVz21zwlH0HzCOSFphrqoaTiX7YT9Vj6PLXI8mRhe w==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="449322731" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449322731" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="831912485" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="831912485" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2023 11:52:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8007D22B; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 08/12] HID: cp2112: Define all GPIO mask and use it Date: Mon, 3 Jul 2023 21:52:18 +0300 Message-Id: <20230703185222.50554-9-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Define all GPIO mask and use it in the driver. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index c8c59d70500e..37ed7fc54770 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -32,6 +32,7 @@ #define CP2112_GPIO_GET_LENGTH 2 #define CP2112_GPIO_SET_LENGTH 3 #define CP2112_GPIO_MAX_GPIO 8 +#define CP2112_GPIO_ALL_GPIO_MASK GENMASK(7, 0) enum { CP2112_GPIO_CONFIG = 0x02, @@ -173,7 +174,7 @@ struct cp2112_device { u8 gpio_prev_state; }; -static int gpio_push_pull = 0xFF; +static int gpio_push_pull = CP2112_GPIO_ALL_GPIO_MASK; module_param(gpio_push_pull, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(gpio_push_pull, "GPIO push-pull configuration bitmask"); @@ -226,7 +227,7 @@ static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) mutex_lock(&dev->lock); buf[0] = CP2112_GPIO_SET; - buf[1] = value ? 0xff : 0; + buf[1] = value ? CP2112_GPIO_ALL_GPIO_MASK : 0; buf[2] = 1 << offset; ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf, From patchwork Mon Jul 3 18:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97290C30654 for ; Mon, 3 Jul 2023 18:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231433AbjGCSwm (ORCPT ); Mon, 3 Jul 2023 14:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231331AbjGCSwf (ORCPT ); Mon, 3 Jul 2023 14:52:35 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D962FE73; Mon, 3 Jul 2023 11:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410352; x=1719946352; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v4C8UxsVUCeBkxMXFBixS/NWejTXhA8uVL1LjjkP2gU=; b=T4rsQjEyrI1fkl9P/+HgQU5+dpKBBEVcpZUVY1QEReSSDHiu6NEq2R4w i46jl0CPhAjLHIhnibDZgq+mCz9YI6cvoLdivPXUhTZ1vdkYAV1IHR3wG Rb6STXV9m+lxFnIvW9I0SXtw2vFkwv+U+FQS5QoAtLhsYgRuwA8gkiO6x +rOBBuR9tWbWO2qyaPHMrnXK/V/kc/ZgMyQnhVQX45Ie5lMOpCPUrH2Q2 x25NXANe3ytRw74+bjexel2/FPUfmvl+gVyK/JCO/T1V/SSl7m6qng/TS BxXdbF0O4Bch7kRncsZMExUFCtTWWZM2KMCD/bJuCGvtfXxUGp8q/OiMl g==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="449322727" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449322727" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="831912484" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="831912484" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2023 11:52:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8B0B5604; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 09/12] HID: cp2112: Use BIT() in GPIO setter and getter Date: Mon, 3 Jul 2023 21:52:19 +0300 Message-Id: <20230703185222.50554-10-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use BIT() in GPIO setter and getter for the sake of consistency with GENMASK() usage elsewhere in the driver. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 37ed7fc54770..2eebb2b19501 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -197,7 +197,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) goto exit; } - buf[1] &= ~(1 << offset); + buf[1] &= ~BIT(offset); buf[2] = gpio_push_pull; ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, @@ -228,7 +228,7 @@ static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) buf[0] = CP2112_GPIO_SET; buf[1] = value ? CP2112_GPIO_ALL_GPIO_MASK : 0; - buf[2] = 1 << offset; + buf[2] = BIT(offset); ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf, CP2112_GPIO_SET_LENGTH, HID_FEATURE_REPORT, From patchwork Mon Jul 3 18:52:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 035C7C30654 for ; Mon, 3 Jul 2023 18:52:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231305AbjGCSwc (ORCPT ); Mon, 3 Jul 2023 14:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231230AbjGCSw3 (ORCPT ); Mon, 3 Jul 2023 14:52:29 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 297F5E64; Mon, 3 Jul 2023 11:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410349; x=1719946349; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AOpwNXsh/T5AKgW2rwkqtZXdctnpIN5g1+lx5hcu/eQ=; b=IHKIiGLepKLudKGOFXzXDpHnMJqntvszdLp6yyQo+wx3Or0X3HgsJnic YuaazsoTyPeZNxNW7eL5s5ZESQsPun8eU+xOLVEpbGrEFgQ+znqCEaIib tSNNTurhwZMNirBnsDd4AOGIjphfWLL0VxCa89/CBXpODSuuj5YH2Pekf YYwV6cCFGuHHamTVVv7eHz8fzgXwSemxnwGgtHDeoc1lISxMohXumHsXx bRCXg/TjGYXrGe89lv4bvBumeHr8lCSayWLSbSnMnKDvfsChHCMvdvrFg iGbEyRR5614v0rogVzNJ2yqAAn0Jzv31alNRbYYnNMasFtRG17fQzEew4 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="362986970" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="362986970" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="721860814" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="721860814" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 03 Jul 2023 11:52:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9C8D369F; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 10/12] HID: cp2112: Use sysfs_emit() to instead of scnprintf() Date: Mon, 3 Jul 2023 21:52:20 +0300 Message-Id: <20230703185222.50554-11-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Follow the advice of the Documentation/filesystems/sysfs.rst and show() should only use sysfs_emit() or sysfs_emit_at() when formatting the value to be returned to user space. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 2eebb2b19501..1e45f5407d09 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -893,7 +893,7 @@ static ssize_t name##_show(struct device *kdev, \ int ret = cp2112_get_usb_config(hdev, &cfg); \ if (ret) \ return ret; \ - return scnprintf(buf, PAGE_SIZE, format, ##__VA_ARGS__); \ + return sysfs_emit(buf, format, ##__VA_ARGS__); \ } \ static DEVICE_ATTR_RW(name); From patchwork Mon Jul 3 18:52:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 699403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCD9DC30657 for ; Mon, 3 Jul 2023 18:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231446AbjGCSwm (ORCPT ); Mon, 3 Jul 2023 14:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231348AbjGCSwf (ORCPT ); Mon, 3 Jul 2023 14:52:35 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57407E7B; Mon, 3 Jul 2023 11:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410353; x=1719946353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lYPz1zqR2x3WBQCDulQo4Jbi7YfCgb1sAO+AUE8NaYA=; b=C48jagK3r8s+dfHvMr47nC+VdKWjvtdvWECCkl7yh4E/XJYG+31WGmq2 OWCpgcNwoK119LRc8oYQ40IRKCd9PK0VeszTN6f5Fs9YeUk/ALwirSI2Q o4I6ZQHDPi1Y4dqoN6pZhJkaLlWn7Nh3JrBMwGQRMvnNIyP2izpelCc8v R51KKRGqVhrnRek4vn6L9g52Wr2kv4ckZ4fP4OYkc0+uVIHwtR68yPAum MOoeNllmcqiPKBSbrF8Csnv+5+lTDsnQdjtplxaGsUlgebXosJrLK1cW2 c6IgrgZrbHw5larhIR8WOGjFdI7nyIDJDY8uq1zdzRaGe+gk1ZNsYNKPr g==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="449322743" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449322743" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="831912489" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="831912489" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2023 11:52:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A2FA869A; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 11/12] HID: cp2112: Convert to DEVICE_ATTR_RW() Date: Mon, 3 Jul 2023 21:52:21 +0300 Message-Id: <20230703185222.50554-12-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Instead of custom wrapper, use DEVICE_tATTR_RW() directly. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 42 ++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 1e45f5407d09..3c6a3be8fc02 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -944,18 +944,10 @@ CP2112_CONFIG_ATTR(release_version, ({ #undef CP2112_CONFIG_ATTR -struct cp2112_pstring_attribute { - struct device_attribute attr; - unsigned char report; -}; - -static ssize_t pstr_store(struct device *kdev, - struct device_attribute *kattr, const char *buf, - size_t count) +static ssize_t pstr_store(struct device *kdev, struct device_attribute *kattr, + const char *buf, size_t count, int number) { struct hid_device *hdev = to_hid_device(kdev); - struct cp2112_pstring_attribute *attr = - container_of(kattr, struct cp2112_pstring_attribute, attr); struct cp2112_string_report report; int ret; @@ -963,7 +955,7 @@ static ssize_t pstr_store(struct device *kdev, ret = utf8s_to_utf16s(buf, count, UTF16_LITTLE_ENDIAN, report.string, ARRAY_SIZE(report.string)); - report.report = attr->report; + report.report = number; report.length = ret * sizeof(report.string[0]) + 2; report.type = USB_DT_STRING; @@ -981,17 +973,15 @@ static ssize_t pstr_store(struct device *kdev, return count; } -static ssize_t pstr_show(struct device *kdev, - struct device_attribute *kattr, char *buf) +static ssize_t pstr_show(struct device *kdev, struct device_attribute *kattr, + char *buf, int number) { struct hid_device *hdev = to_hid_device(kdev); - struct cp2112_pstring_attribute *attr = - container_of(kattr, struct cp2112_pstring_attribute, attr); struct cp2112_string_report report; u8 length; int ret; - ret = cp2112_hid_get(hdev, attr->report, (u8 *)&report.contents, + ret = cp2112_hid_get(hdev, number, (u8 *)&report.contents, sizeof(report.contents), HID_FEATURE_REPORT); if (ret < 3) { hid_err(hdev, "error reading %s string: %d\n", kattr->attr.name, @@ -1016,10 +1006,16 @@ static ssize_t pstr_show(struct device *kdev, } #define CP2112_PSTR_ATTR(name, _report) \ -static struct cp2112_pstring_attribute dev_attr_##name = { \ - .attr = __ATTR(name, (S_IWUSR | S_IRUGO), pstr_show, pstr_store), \ - .report = _report, \ -}; +static ssize_t name##_store(struct device *kdev, struct device_attribute *kattr, \ + const char *buf, size_t count) \ +{ \ + return pstr_store(kdev, kattr, buf, count, _report); \ +} \ +static ssize_t name##_show(struct device *kdev, struct device_attribute *kattr, char *buf) \ +{ \ + return pstr_show(kdev, kattr, buf, _report); \ +} \ +static DEVICE_ATTR_RW(name); CP2112_PSTR_ATTR(manufacturer, CP2112_MANUFACTURER_STRING); CP2112_PSTR_ATTR(product, CP2112_PRODUCT_STRING); @@ -1034,9 +1030,9 @@ static const struct attribute_group cp2112_attr_group = { &dev_attr_max_power.attr, &dev_attr_power_mode.attr, &dev_attr_release_version.attr, - &dev_attr_manufacturer.attr.attr, - &dev_attr_product.attr.attr, - &dev_attr_serial.attr.attr, + &dev_attr_manufacturer.attr, + &dev_attr_product.attr, + &dev_attr_serial.attr, NULL } }; From patchwork Mon Jul 3 18:52:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 698873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D15E6C30658 for ; Mon, 3 Jul 2023 18:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231403AbjGCSwn (ORCPT ); Mon, 3 Jul 2023 14:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231349AbjGCSwf (ORCPT ); Mon, 3 Jul 2023 14:52:35 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F18C2E7D; Mon, 3 Jul 2023 11:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688410353; x=1719946353; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Mym6i/tgEoTAGg7H2qslE07ns2in3+2GRLlg1GCRN9A=; b=RlT90CFGm+HhAHm8GG5kZuGftH0fuX7HV5Vcv9faqtw2ufVBQhSKcJfZ x1QJdUCLGXhhX0TbCmGtuhnh5tJ0tZ+Px3Ea2CvT31mcDP25mXDjxZZFU UI4/nyIxgLMf19iUQfpZ1bZNRyo+AqwUVPeE0+YwpofxLf5S9EHB1HzWH IB+i9w5YCKpssXKqq9jkkJFlqtguZgsqMCrHcjl+8Il5cvGGd3NG9GNI6 3ziJ4se32uzzZZJ04jQQmtfow1TTSOYo5LJxNmSeoC3c5lxEh38q1iTR8 OKDa2DDrytnrBQw0uhzSG1EwZY45s+Wn30pa/Cx+lIWOzHIUUsmx/eUEf g==; X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="449322739" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="449322739" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jul 2023 11:52:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10760"; a="831912490" X-IronPort-AV: E=Sophos;i="6.01,178,1684825200"; d="scan'208";a="831912490" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2023 11:52:27 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id BF7C2718; Mon, 3 Jul 2023 21:52:27 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Andy Shevchenko Subject: [PATCH v1 12/12] HID: cp2112: Use octal permissions Date: Mon, 3 Jul 2023 21:52:22 +0300 Message-Id: <20230703185222.50554-13-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> References: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Octal permissions are preferred as stated in Documentation/dev-tools/checkpatch.rst. Replace symbolic permissions with octal permissions when creating the files. Signed-off-by: Andy Shevchenko --- drivers/hid/hid-cp2112.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 3c6a3be8fc02..adbe8a47cf67 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -175,7 +175,7 @@ struct cp2112_device { }; static int gpio_push_pull = CP2112_GPIO_ALL_GPIO_MASK; -module_param(gpio_push_pull, int, S_IRUGO | S_IWUSR); +module_param(gpio_push_pull, int, 0644); MODULE_PARM_DESC(gpio_push_pull, "GPIO push-pull configuration bitmask"); static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) @@ -1057,7 +1057,7 @@ static void chmod_sysfs_attrs(struct hid_device *hdev) } for (attr = cp2112_attr_group.attrs; *attr; ++attr) { - umode_t mode = (buf[1] & 1) ? S_IWUSR | S_IRUGO : S_IRUGO; + umode_t mode = (buf[1] & 1) ? 0644: 0444; ret = sysfs_chmod_file(&hdev->dev.kobj, *attr, mode); if (ret < 0) hid_err(hdev, "error chmoding sysfs file %s\n",