Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5785074ybc; Wed, 27 Nov 2019 09:22:17 -0800 (PST) X-Google-Smtp-Source: APXvYqwEfB747DvSmDVSVxByZI6YzhAPQ2qPzc02VyKz+IZoBURAG9r1GbWwnNJI5qzfTb2xI+DY X-Received: by 2002:aa7:c74e:: with SMTP id c14mr33785343eds.260.1574875337321; Wed, 27 Nov 2019 09:22:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574875337; cv=none; d=google.com; s=arc-20160816; b=HJGmoK4tfd60/iowIJlJnNxXbEMjRvUq0ASnU7KnB/pChEXf8mpF66B0qcUnS/Ntxo Ds5vK/EFgnsNMr56mMqEwCoq5R3kY7bG9Slt32p6f+OppjW3EYrjBT1I86TS998AYKeV WCD5xqsRbU4Mu1NOyE6V9/3RbQDHi+TM2OYEFhioTql6O5/c0DzxlgX2J78sBrY2eWHP CZ3uDU7en1JvgQieI88hUEm5oAZvaHoTLd7V/laLFWBu3DJgz9ZYM5W/F81UYOHfKpFY mOGMsp1qlJUZ9Qy3gqAs9My7x52di+4bBbPkKpONzB+oU0hiVSLfWwx7iGtfio0GoJqv mXEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=O1Wv5Fa6y5WJzpCbaVLHvSntoRioiZULlQIXnav1cKs=; b=Kz3Twm3AyWYhaGakwoQ9w/Goq6LMzmDy9glJ4YcSTibUl/JzgQr3p9HaQMJqMoMIcE nHYWRDHShPSdcj1odyJE8UlRxv0uNjKhR/FtSZ14VB1FoolKzhQEk1RnNmwat7wNxjVb rvn2a1PIXfTbisPZvuQYuY+S9N+DgVaYJQ6Cm1r85bvZXc5CUkEd74o1z5s5sY6S05XB d0szycGTymCj9novHWLmWuLIvHrDwM9Pw7dCjh9F52hHz/9dGvK2oZwUM0kOrmAwYs19 FPNajxxUQbvkctPlSMJpl4IYvBG5K1iUoCA0H1DIEjBkiFp/b2zZsKSqGWL5TyQU6rD/ h6Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=grXg6Fp+; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h49si11162190edh.2.2019.11.27.09.21.37; Wed, 27 Nov 2019 09:22:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=grXg6Fp+; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbfK0RVg (ORCPT + 99 others); Wed, 27 Nov 2019 12:21:36 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:37429 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726655AbfK0RVg (ORCPT ); Wed, 27 Nov 2019 12:21:36 -0500 Received: by mail-qk1-f196.google.com with SMTP id e187so20225106qkf.4 for ; Wed, 27 Nov 2019 09:21:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=O1Wv5Fa6y5WJzpCbaVLHvSntoRioiZULlQIXnav1cKs=; b=grXg6Fp+3O+OBf4RntdOJlUA3vx0n0EwlB68dbsopOr//2uIYLSLXRgiywaODMPFp8 lAVNCK9K5sdi4cLWtThJWKu5oVEuQ34M+6vROqMXlS5P9uN307Jstwke0R8xXcG4lmll urg/OA0AP5gb0CSGgGwkimkdIe79ca28acZYA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=O1Wv5Fa6y5WJzpCbaVLHvSntoRioiZULlQIXnav1cKs=; b=aU2XdOGCrjgTo68VA/lNs6dBWUmtxkt2745o8cBToZ1rW69uIQ+VEReW2Sq0JGUpJM 51Ytsi84R43+4TV7q1ejdg20KzW1ypAx36CM9uR+w16BQ0/HYTaHkToNcQ0qwXojxp82 zDTouAicifwmtb7QUsD/ddHoOpnen85k2Dnkd6MKwnp7+nslbuKVV6OhDLwtKvig3cSU 5NrHvBgn4afBc4OsGssULZisOeKJyf0F6uFoLfNMY9QMj737ilYavHjr/ySZxDxLZn8c q2GZbmiwMZSxAP4YQ6+CdGPCdDCJe4wAcqJBiD08McMi7N4kOLTUav2NP1Qy+7WWWuB0 QuSA== X-Gm-Message-State: APjAAAUTDtIpscqaRzNKg33mJaRJGWKyNuKk1on3yaEiVTHQrNXSvOsr dlSEawJtqfY0LALsUBr00nq12qyMBS250U2PW/tyrg== X-Received: by 2002:a05:620a:796:: with SMTP id 22mr4381875qka.419.1574875295112; Wed, 27 Nov 2019 09:21:35 -0800 (PST) MIME-Version: 1.0 References: <20191126212753.18455-1-pali.rohar@gmail.com> <20191127160720.aleatv6l4swopg57@pali> In-Reply-To: <20191127160720.aleatv6l4swopg57@pali> From: Abhishek Pandit-Subedi Date: Wed, 27 Nov 2019 09:21:24 -0800 Message-ID: Subject: Re: [PATCH] avctp: Set more descriptive name for uinput device To: =?UTF-8?Q?Pali_Roh=C3=A1r?= Cc: Luiz Augusto von Dentz , "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On Wed, Nov 27, 2019 at 8:07 AM Pali Roh=C3=A1r wrot= e: > > Hi! > > On Wednesday 27 November 2019 17:50:40 Luiz Augusto von Dentz wrote: > > Hi Pali, > > > > On Tue, Nov 26, 2019 at 11:31 PM Pali Roh=C3=A1r = wrote: > > > > > > --- > > > profiles/audio/avctp.c | 3 +-- > > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > > > diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c > > > index 70a3e40b2..ae53587ad 100644 > > > --- a/profiles/audio/avctp.c > > > +++ b/profiles/audio/avctp.c > > > @@ -1181,8 +1181,7 @@ static int uinput_create(char *name) > > > } > > > > > > memset(&dev, 0, sizeof(dev)); > > > - if (name) > > > - strncpy(dev.name, name, UINPUT_MAX_NAME_SIZE - 1); > > > + snprintf(dev.name, sizeof(dev.name), "Bluetooth Audio/Video R= emote Control%s%s", name ? " " : "", name ? name : ""); > > > > > > dev.id.bustype =3D BUS_BLUETOOTH; > > > dev.id.vendor =3D 0x0000; > > > -- > > > 2.11.0 > > > > It is already setting a bustype to BUS_BLUETOOTH why do you need to > > make it more specific, > > Because more tools shows only device name. Also in kernel dmesg is only > device name. And MAC address is really something which does not say > anything about device... > > For this reason also older input devices (implemented in kernel) exports > more descriptive names, e.g. "AT Translated Set 2 keyboard" or "ETPS/2 > Elantech TrackPoint" or "Integrated IR Camera". > > > btw it needs to be limited to UINPUT_MAX_NAME_SIZE. > > Is not this implicitly defined by sizeof()? > > > Id say if we want to make it declare the connection type > > Yes, connection type would be really useful. > > Now I'm playing with exporting "button press even" from HSP profile via > uinput device too and therefore connection type should be there. > > > that probably something that needs to be encoded in > > the bus itself, like BUS_BLUETOOTH_AVCTP, BUS_BLUETOOTH_HOG, etc. > > But bus type is kernel API and there is no such AVCTP or HOG. So we need > to stick with BUS_BLUETOOH. > > Other kernel devices also put protocol information into name (e.g. > touchpad / trackpoints), so it is ideal place also for bluetooth > devices. > > And probably most userspace devices are mapped to BUS_VIRTUAL. There > are no subtypes. > > -- > Pali Roh=C3=A1r > pali.rohar@gmail.com Wouldn't it be better to use the device name for uinput rather than the add= ress? In `init_uinput` (avctp.c), uinput_create is called with device_get_address instead of device_get_name. It would probably be better to use the device name for the uinput and set the device address as the `uniq` attribute (as it is done for /dev/uhid for HID devices). So in the following, replace ATTR{name} with something like "Some Company Headphones", ATTR{uniq} =3D "33:33:33:ff:ff:ff" and ATTR{phys} with the controller's address. $ udevadm info -a -p /sys/devices/virtual/input/input21/ ... looking at device '/devices/virtual/input/input21': KERNEL=3D=3D"input21" SUBSYSTEM=3D=3D"input" DRIVER=3D=3D"" ATTR{inhibited}=3D=3D"0" ATTR{name}=3D=3D"33:33:33:FF:FF:FF" ATTR{phys}=3D=3D"" ATTR{properties}=3D=3D"0" ATTR{uniq}=3D=3D"" This is what uhid looks like in comparison: $ udevadm info -a -p /sys/class/misc/uhid/0005\:046D\:B33B.0002/input/input= 18/ looking at device '/devices/virtual/misc/uhid/0005:046D:B33B.0002/input/input18': KERNEL=3D=3D"input17" SUBSYSTEM=3D=3D"input" DRIVER=3D=3D"" ATTR{inhibited}=3D=3D"0" ATTR{name}=3D=3D"Keyboard K780 Keyboard" ATTR{phys}=3D=3D"ab:cd:ef:12:34:56" ATTR{properties}=3D=3D"0" ATTR{uniq}=3D=3D"33:33:33:33:ff:ff" Abhishek