Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp970580ybl; Thu, 23 Jan 2020 11:05:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwxb4D9ADcLwtujYNxYTmkauxsXQrfpDcjJoiBx7vBGY+F+UapY6pG5wwOGYMO7RtIVCT6O X-Received: by 2002:a05:6830:4a4:: with SMTP id l4mr6577355otd.91.1579806320381; Thu, 23 Jan 2020 11:05:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579806320; cv=none; d=google.com; s=arc-20160816; b=jvd7vZuA2SOae3IWo05PC+lDwhIBKQn9S6U7LddOzUzkzbiIuTW+wKptN9Yb2g2SDv cJARIZ+AErUzQWKDmcyFL9omeYfd1s+adYug5ixK/nxNVPLAGbS+LaE0tzPqNppyNkyP b5UlF58eSg6Crx/17bf7yXI1JQO3MMdAoz1f+Hl9S+FrhN+qoql2sKg47E6xW7oRmQd/ AQ/F48ov355f2gtNiDI8QkxAaIopOr69DPUDAXMx4pMUVRb1148h+Bfrz8I5H2N3B9Sd vBoewToAVxc0OPmUYzYOlNhxmyni9/gPxlpEj3Gxm/h09jvd8dJIqaryZ0rL+rTuKgEL 2SSg== 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=fmLMVkRzp/N1hHBHLYR1mm/ggH3hz1NN7z2tuRzXhQM=; b=qocsTdEfxRIBRJ9fWnaBHfmHHqJMFV97NW8vork8OhknIIWT8trv9QG6gKe3f/nirO zGsHpYwjIZE2co8tOtyNXD1JoYuhLnBg23QNE8ONM2EchAv2BoZgbCpv7jsfcbaW5XWu 3Wr4VCDanuJG+lWJ1LwrPAX6VArssHcg0BtbOYJ40CyQmUKvCCNay/NFxeXKCsskhcxt 4Nn9af5Tso5704CX6VHar53NFOvXMIToqlTn6UVMuZRFXw7Tz3JBxHsTuzbfhQWcm9SJ 069trChWUeeMRQGPc3mKnTR3EXutb0Ax6KEsqbFqMKU8mZjRU9Wk8g0c7eijdeQvaKBq 9vGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=i4yeCYkn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b145si1208494oii.67.2020.01.23.11.04.48; Thu, 23 Jan 2020 11:05:20 -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=@google.com header.s=20161025 header.b=i4yeCYkn; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbgAWTE1 (ORCPT + 99 others); Thu, 23 Jan 2020 14:04:27 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37500 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728057AbgAWTE1 (ORCPT ); Thu, 23 Jan 2020 14:04:27 -0500 Received: by mail-lj1-f193.google.com with SMTP id o13so4862245ljg.4 for ; Thu, 23 Jan 2020 11:04:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=fmLMVkRzp/N1hHBHLYR1mm/ggH3hz1NN7z2tuRzXhQM=; b=i4yeCYknX+xaYoSzQtuY2UnnyEkZ6as2BlW03jraookWmDEcpxCLMGhe5eBjWlg8IN 7fqsZKCYmvQFuM6Rrn4k/vqLBcpWIcBJK71xpW0Bs1L9jpTlxUbAQ/Ewk9HoXouMbev6 UXdj7qfzYXc5Pv7QVRTXCCR2dQklRmSeSuNpZFGHDXWQqbjYNmqbMRydSz5caAaDff8d K/SnSFsIlDGRMK8pyV2G+NFX5whb8HRdYLZbUIKUoZObQBS45dAtCUpxUf0c4MO6m6uh CXiONTD9epgA5ukzkJRZm7B4QabhHx1j7Wt7PQJP/g+Pr18ycPFLVKHSsYT8tH46U+dE DTog== 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=fmLMVkRzp/N1hHBHLYR1mm/ggH3hz1NN7z2tuRzXhQM=; b=QqFbJHr3Qu+ju+shzSHD6jU15gN76XPwSf8gL3GNU7M34Ay2d2Zwgca8N3QNrlcov0 9SM6JCOh/RCwvBc3sNTPPrsZiURehqNng7N5L20K1uSQ2ktHyFQhISu1s7qP4SpBofgB +5IFHJ9qkmqsMO/ZDYivTWWCB3VQvnf2kUj2yaswRcz6Oe39Cs1J/IA0+cTZx0SkIHdR dhsbA/+gqsRb2GdJJ6gbt90G+cf2cSjdWeEWHzFkEsaVcfiQejDQwWoYVVMqPhrCB6Ps PDI36Z8nc/bCuMeBWiZfPAYFr1nfagOMDcoQ4+rlMeQXANwzpSExtwIZr3clwkndH101 Ul7g== X-Gm-Message-State: APjAAAWjVMTKGNwO7XBiOigYBN5FpOUUHcHAkWOGzxZ5rC6R/QqOpwOZ gQYeesbxuD8y61/938jOq8c/ZUvRRJuDR82K/xkD8g== X-Received: by 2002:a2e:884c:: with SMTP id z12mr36209ljj.55.1579806265208; Thu, 23 Jan 2020 11:04:25 -0800 (PST) MIME-Version: 1.0 References: <20200118050410.257697-1-alainm@chromium.org> <37FDD376-5D3D-484C-9209-B59FACA22D0A@holtmann.org> <6EF3C3FB-89A6-4B23-A4F5-ADC59FFB9F98@holtmann.org> In-Reply-To: <6EF3C3FB-89A6-4B23-A4F5-ADC59FFB9F98@holtmann.org> From: Alain Michaud Date: Thu, 23 Jan 2020 14:04:14 -0500 Message-ID: Subject: Re: [PATCH v2] bluetooth: Refactoring mgmt cmd op_code structure To: Marcel Holtmann Cc: Alain Michaud , BlueZ 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 Thu, Jan 23, 2020 at 1:42 PM Marcel Holtmann wrote= : > > Hi Alain, > > > I'll separate the simple one liner into a separate patch then will > > wait for your suggestion for the rest. Note that with a single jump > > table as suggested, it will indeed allow us to defunc some op-codes > > pretty easily. > > I have not fully thought this through yet, but here it goes. > > The read_version and read_commands are special since they have to be pres= ent no matter what. So on purpose we put these two commands first when we d= esigned the API back in the days. We can special handle them and thus also = avoid the forward declaration. I am leaning towards this direction since we= might want to actually split commands over multiple files to keep this fil= e readable over time. > > Now the downside with putting the opcode as a field in the data structure= is that we actually have to look through the every field until we find the= opcode and can not just jump to the position defined by that opcode. That = means actually filling the table with NULL pointers for not supported or di= sable commands might be better. We could still make the read_commands funct= ion map the list of supported commands from that table. That may be an acceptable compromise. At least there would be exactly one place to make sure things are aligned. Perhaps we could also leave the op-codes in place and create a test that ensures that if !NULL then op_code =3D=3D index. > > This will still not fix the list of supported events since that is still = static and will require manual patching. Agreed and actually events are less problematic as there is no jump table to fix up. As long as it is in the supported events list, then it works out pretty well, regardless of order... > > Regards > > Marcel >