Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp519170lqp; Thu, 21 Mar 2024 08:01:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX/VmeAH9YmitFL6GgkfKdQrLpEGQi93OfrF3fd62PNryPTbsuBjWafJTjOlvO9Jd5aH+fP8oIea9bpVWEu7VFHHl7T8MEEcGQ65jZSxg== X-Google-Smtp-Source: AGHT+IElw0v9eewfwRpy8jeYOk8DI12JStPQF2OVEyL8iiuGcxb6lWmRrl3CIiuCt3sCHOQf/XhV X-Received: by 2002:a17:906:3457:b0:a46:c822:7f2 with SMTP id d23-20020a170906345700b00a46c82207f2mr1531899ejb.2.1711033284972; Thu, 21 Mar 2024 08:01:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711033284; cv=pass; d=google.com; s=arc-20160816; b=IUKNAKoCKuBlrvUDhwdzw66dO2YP1RUQig2VVmYi3nWPnKPkHCraMpihWAYrFZ4+yh T8WDZii71iZRykoQ88yhgAcAc8IA9/8K3nK+fYrAOpkaWwnr+vF5g5+f6ZZJsNR2QRTu 19NB6gGNVfHU3Uzlf3J0jWpDVn9/euI9yuYVzR2l+Z6JoxUsqTb7My5t4rckABnG51bZ PCw2YvrZb/B7u5LeyaKhYelEdt9x2r9gZdKxx0GdakeqmcHAw3I+i0OGnJkDZDH6aDAA MXu36uFPje8rxjlqlIPgqj6vvqMGrrI5GEePxMnPiaGLAnRkmEt54hS8ttCkm396z5LF A/YQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zyfG/nQmjJt++W/Bo2LpplGkNomzREov8OiA+X/whHw=; fh=1Uf5DkdVtAZA/qQa11rdvNSJiTl0oEcuHuUuNSksnOA=; b=ijYYh+AHTVymdeVL92zFJZL+TKjGAfGaGxRPvLeitofk/6B09Hj1tVw/OVvCfalrum OHU4X8KlnenjRGQmD/DXBK1gPo5caLvFZryr72J3uJfjUxbDl7EBkOVL5Vk1gbSiZVaf NJ7LwIYVMPXlHjzc8Xt2ByfRyUlabRscpSRg8IqFfq4wbogIHjxk2r0eaDxZbnGr07+j ZWpNmTEKNb6pKGrB3JXXUFTFlQOXIVeF+YKixZQC9eyVS0NSa5OgLL+o7yFhuVI1PPAw Yp353Nzt1jjdWKKB81V0k8EgHAwj+2GttEIeOpRADtjlIHR5Rws5JDGhHtICQ1h+5znt LYyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K6LV5WN3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-110188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q22-20020a170906145600b00a44e6d729f0si1291ejc.897.2024.03.21.08.01.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 08:01:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K6LV5WN3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-110188-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110188-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B09001F22136 for ; Thu, 21 Mar 2024 15:01:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2BE48615F; Thu, 21 Mar 2024 15:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K6LV5WN3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E462155792; Thu, 21 Mar 2024 15:01:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711033272; cv=none; b=MbPvBGcAtK4EvipYUWC3JT0/ziHPukT3UH59U2xf1MhVWmZWZ3ERFHfCVl/FdkO/G9djOZ0xEvFoynv5btR79C7ipuZC5YpegZEjQiLSwizzUURCsAdc9i+kNeTtWbCiqmgho/z+mw7EK8vJixsmTfxs0mI+fLGfDoaIcFR5/+o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711033272; c=relaxed/simple; bh=PEJrHSKt1U+K2L5GVnfRCuafwN7gw0OYFsINbYiBTdE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pHx4i6QuDYUBmTUYXVFIeDKTTCOtVERy8Ckj68iz1ipQ/aMaVwja5YljDTfgg+Iha1GqnIfnT6aHfuI9fp1jORNFkf/N5gJlLC3wPSlpDEmkZ3smcgnWEAdZoaN5WxnwaJ3tYwnh3X+4tdeqSfl5Mo8A6ni9h6VOn486dN+4K7Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K6LV5WN3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 223A7C433F1; Thu, 21 Mar 2024 15:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711033271; bh=PEJrHSKt1U+K2L5GVnfRCuafwN7gw0OYFsINbYiBTdE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K6LV5WN3cJeKpxPr3PEudhZ0rutxUFjpiz3rzcP/5XF2mJaGCmyGDuWItvM5/n1iZ COlgIKNmhcOb9DYaAS6ZdSy/HZ/CHws+xOsblsl48Vrd5RDmc+XfABK4KocwyhQA1C dN64eFtIXZijfLOG6/6vHR2aTpyz3yHWeUVCEn/NikbQDND8CcmYNvkUnAykAAk26d yBJ9zVEE/S2/2TS6E7/fYHA5t9wuOH4mec2abjoSpOXUZ+DiBCbcwTrtYsjIgnNB1x yaKSy2LARjVFcd5pG6sxsynBawEy51576AMJONfeQRIsQ21FsySBxdYfyJB4CjKTzJ QPwyEdJFtIBOA== Date: Thu, 21 Mar 2024 16:01:06 +0100 From: Benjamin Tissoires To: =?utf-8?B?Sm9zw6kgRXhww7NzaXRv?= Cc: jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] HID: uclogic: Store firmware name in params Message-ID: References: <20240321144553.262409-1-jose.exposito89@gmail.com> <20240321144553.262409-2-jose.exposito89@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240321144553.262409-2-jose.exposito89@gmail.com> Hi Jos?, On Mar 21 2024, Jos? Exp?sito wrote: > A future patch will need to access the firmware name to expose it to > userspace via sysfs. > > Store it in `uclogic_params->fw_name`. > > Signed-off-by: Jos? Exp?sito > --- > drivers/hid/hid-uclogic-params.c | 14 +++++++------- > drivers/hid/hid-uclogic-params.h | 5 +++++ > 2 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c > index 9859dad36495..79ec3eb80f84 100644 > --- a/drivers/hid/hid-uclogic-params.c > +++ b/drivers/hid/hid-uclogic-params.c > @@ -121,6 +121,7 @@ void uclogic_params_hid_dbg(const struct hid_device *hdev, > params->invalid ? "true" : "false"); > hid_dbg(hdev, ".desc_ptr = %p\n", params->desc_ptr); > hid_dbg(hdev, ".desc_size = %u\n", params->desc_size); > + hid_dbg(hdev, ".fw_name = %s\n", params->fw_name); > hid_dbg(hdev, ".pen = {\n"); > uclogic_params_pen_hid_dbg(hdev, ¶ms->pen); > hid_dbg(hdev, "\t}\n"); > @@ -652,6 +653,7 @@ void uclogic_params_cleanup(struct uclogic_params *params) > if (!params->invalid) { > size_t i; > kfree(params->desc_ptr); > + kfree(params->fw_name); > uclogic_params_pen_cleanup(¶ms->pen); > for (i = 0; i < ARRAY_SIZE(params->frame_list); i++) > uclogic_params_frame_cleanup(¶ms->frame_list[i]); > @@ -837,7 +839,6 @@ static int uclogic_params_huion_init(struct uclogic_params *params, > /* The resulting parameters (noop) */ > struct uclogic_params p = {0, }; > static const char transition_ver[] = "HUION_T153_160607"; > - char *ver_ptr = NULL; > const size_t ver_len = sizeof(transition_ver) + 1; > __u8 *params_ptr = NULL; > size_t params_len = 0; > @@ -870,14 +871,14 @@ static int uclogic_params_huion_init(struct uclogic_params *params, > } > > /* Try to get firmware version */ > - ver_ptr = kzalloc(ver_len, GFP_KERNEL); > - if (ver_ptr == NULL) { > + p.fw_name = kzalloc(ver_len, GFP_KERNEL); > + if (!p.fw_name) { > rc = -ENOMEM; > goto cleanup; > } > - rc = usb_string(udev, 201, ver_ptr, ver_len); > + rc = usb_string(udev, 201, p.fw_name, ver_len); > if (rc == -EPIPE) { > - *ver_ptr = '\0'; > + *p.fw_name = '\0'; > } else if (rc < 0) { > hid_err(hdev, > "failed retrieving Huion firmware version: %d\n", rc); > @@ -885,7 +886,7 @@ static int uclogic_params_huion_init(struct uclogic_params *params, > } > > /* If this is a transition firmware */ > - if (strcmp(ver_ptr, transition_ver) == 0) { > + if (strcmp(p.fw_name, transition_ver) == 0) { > hid_dbg(hdev, > "transition firmware detected, not probing pen v2 parameters\n"); > } else { > @@ -1028,7 +1029,6 @@ static int uclogic_params_huion_init(struct uclogic_params *params, > rc = 0; > cleanup: > kfree(params_ptr); > - kfree(ver_ptr); > uclogic_params_cleanup(&p); > return rc; > } > diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h > index d6ffadb2f601..412c916770f5 100644 > --- a/drivers/hid/hid-uclogic-params.h > +++ b/drivers/hid/hid-uclogic-params.h > @@ -232,6 +232,11 @@ struct uclogic_params { > * List of event hooks. > */ > struct uclogic_raw_event_hook *event_hooks; > + /* > + * Firmware name, exposed to userspace via sysfs as it is used to > + * identify the tablet. > + */ > + char *fw_name; I can't remember if this was on the table or not, but any reasons to not use hid->uniq[64] field instead of a custom sysfs? If there is already a value, we could just append the firmware version with a colon (:) separator. The main reason would be to not export a new sysfs specifically for this driver, but it would also allow HID-BPF to have access to the value and thus allow to detect if the device works with the given bpf program. Cheers, Benjamin > }; > > /* Driver data */ > -- > 2.44.0 >