Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp951845ybl; Thu, 23 Jan 2020 10:43:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyeiWACaDe3YQS8F54JAYMH1WAhipECCsLDPdNxkpSg24SH70zbieiMkGsGkJ99vky85dE4 X-Received: by 2002:aca:110a:: with SMTP id 10mr11688373oir.130.1579804983637; Thu, 23 Jan 2020 10:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579804983; cv=none; d=google.com; s=arc-20160816; b=GjeH13Y1dhWx3cBP4knJMXznCv/Up+NQ/P+Oc3lWawmKJssGNDW4ZRqZbLQfauvUVQ InocRbS8niASPfetNNcHVwaS7E4ZwGez71fCQ9xov2a4mlT9rUS7qN3ACJDup1tXR2kY 1+MLOMeTZ7XgulieFx1pj0R3xNV6PMaGNZKM4RPLeldeMob4kK0wfAm5zutrHoaGLtOg ll9ehGS/9ggi4BJrTBlMrLkQKgBuBQawhDWxM64G4wpBCZSLndacbPeXtYXqrGNZeQYH k0GN5ogBiw7mec9/FyUfrPLUVx7Oe5h6BaglORU9ybyCEnPgII6eIlv2bNLj6NSAulgE Y8Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=LKXKiEkxHjqmsI7Ce8c9r3B2UbKeVf+xWVjrl5ptCxI=; b=EzWWSpfB3UlryFAjQL6A/JmCwQvsJsGeqlzAV6H3KeBeitp7HZBr1JhCqsD9nJs2kS FRjuNXc6wNxWLXv5CJ12oz5Ew6Htv+PHe6d4MZp1qQG7FmOYvtpogxq5A8BITe7RjBrk 3d11W4HaDX1DhwYe0P3kNj/R6qnK7guepFYGAeOIviq0tPMMVbNdIQUFUiFJaY7vT4A5 /iszMNJWr+JNf7xC33MDy7lX0aufvW74inDfoHGtpRt0otEh8/Ct0D2k+NjclcK+YqrP dt2Vrvh+Lm7BNcay7ff5ub50QDpEjYJ9TjGdLbPdldF+DGdiCz4545yj5Z6po+wRn11S gCwA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l84si1206990oig.5.2020.01.23.10.42.39; Thu, 23 Jan 2020 10:43:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728899AbgAWSmN convert rfc822-to-8bit (ORCPT + 99 others); Thu, 23 Jan 2020 13:42:13 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:35089 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728797AbgAWSmN (ORCPT ); Thu, 23 Jan 2020 13:42:13 -0500 Received: from marcel-macpro.fritz.box (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 3601ACED02; Thu, 23 Jan 2020 19:51:31 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) Subject: Re: [PATCH v2] bluetooth: Refactoring mgmt cmd op_code structure From: Marcel Holtmann In-Reply-To: Date: Thu, 23 Jan 2020 19:42:11 +0100 Cc: Alain Michaud , BlueZ Content-Transfer-Encoding: 8BIT Message-Id: <6EF3C3FB-89A6-4B23-A4F5-ADC59FFB9F98@holtmann.org> References: <20200118050410.257697-1-alainm@chromium.org> <37FDD376-5D3D-484C-9209-B59FACA22D0A@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.40.2.2.4) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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 present no matter what. So on purpose we put these two commands first when we designed 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 file 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 disable commands might be better. We could still make the read_commands function map the list of supported commands from that table. This will still not fix the list of supported events since that is still static and will require manual patching. Regards Marcel