Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2250648imm; Thu, 27 Sep 2018 09:41:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV61qmMKw0DPDnzcg8LvmiF3+OMU42HNHRRXzGXSQDEM6/1k9DOEkIfm687RLj7OQTZP9HOEg X-Received: by 2002:a63:6445:: with SMTP id y66-v6mr11253446pgb.443.1538066517445; Thu, 27 Sep 2018 09:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538066517; cv=none; d=google.com; s=arc-20160816; b=nZ6tne86SI0uEMF5uKA/K+Dr60VOzbx2kQWqnoSb0b/wDu/oohV3fHFB//P1OMb70m CFsPtooONyT3Lhd3+WaP0hXFtHMeGIGDXvMs/glcsRTIn0MpiNAsbwzXOFWWaSdeqlsy vQXIizAa6UyzWNwWwZUkJWUSLSxj+9jSUBL8HnMY6ETSm3/GvULp+JV7ZxLZL/slV9Dz mVfZ0FSkvPUmYZC2MrHucLYqa4Qs8ZGuBFLU4yf+pX94K96Io/QybefZ1zfpPSh1nq+3 zCObanE5pN1R+C+YPVN3ANuT5yG3mN+FAc5reAgl9K7XkWyjGl8Mr15WzwHLptSEAu89 Tzdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=z5SPgkyhpaafHQpguYQOU7snyAlCWf6jzb09jXVVm2w=; b=jtZNhIlDy28iiq7hsRn/+EeHmR9JIFyAc7aH4ceXQgefZ96ailMG0UZJI4v96ykxS+ BatOTstWtQn+B+51oX5Cagqtj6sfSFx+BMxLVQNcSjV33jnZEdr7CgzoNkRZPX983cP8 LN6unBd3ciaz0YSgezA3h+jyv8Dw5CZjgo7lSJhatCFPbfYC/EM5ZmC1tr+6IEeoNR6Y Pt99gxlctCO6fnOknMBYyiC26E2sHXgZ0tMA8JOW0jUvZEWLSVJrC8Nx3Ri0C5a0QYz9 IRYQQv06avX1p/mTsAWivl31MVj16AdWvLvwG03JJxS6+WGNU/YvrMaFxHmXHYVtRPM8 WZQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=JI0T5Q3j; dkim=pass header.i=@codeaurora.org header.s=default header.b=fTagY7NZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 cd15-v6si2619993plb.219.2018.09.27.09.41.40; Thu, 27 Sep 2018 09:41:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@codeaurora.org header.s=default header.b=JI0T5Q3j; dkim=pass header.i=@codeaurora.org header.s=default header.b=fTagY7NZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728117AbeI0XAS (ORCPT + 99 others); Thu, 27 Sep 2018 19:00:18 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47996 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727338AbeI0XAS (ORCPT ); Thu, 27 Sep 2018 19:00:18 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 72BE1605FF; Thu, 27 Sep 2018 16:41:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538066471; bh=8lHHPy2z1uiGwv+/qmUouiS8IzTdiybfQfffdZkv088=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JI0T5Q3jkFVUWhEEPJ9Rc3ztAHVJ7HGrNFTGaCFu2TOosqVbvJ9qlvoAdgFyNnDuA JTKNdWSlIjwVB9BUsBG5SntYLRyE4oGGeRbRK+KB4LLp/CXBCK1qIJBSCUMGBtxHCx iP00dnZg4cJIk64BGEYmy58FQ+6RGqQtjlIc0llY= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 6CF8960275; Thu, 27 Sep 2018 16:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538066470; bh=8lHHPy2z1uiGwv+/qmUouiS8IzTdiybfQfffdZkv088=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=fTagY7NZOyfvU5G/r2lmWoUNDXEOF4PE54Odp6R4yY86YqtPY4vs89LrK/KB8QhhJ 18lwSxQGmzbSU9z5LMFddZrgpy5pSvz80ZiMoxt64jbhmGH0xAk4wk4PikohiiORpq 8+29N+opLosw//MLJXgwp9iadqX1XyyMIERzFo88= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 27 Sep 2018 22:11:10 +0530 From: Balakrishna Godavarthi To: Matthias Kaehlcke Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , Sakari Ailus , Marcin Wojtas , Andy Shevchenko Andy Shevchenko , Sinan Kaya , Marcel Holtmann , Johan Hedberg , linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, Loic Poulain , Brian Norris Subject: Re: [PATCH v4 1/2] Bluetooth: Add device_get_bd_address() In-Reply-To: <20180927004810.124185-2-mka@chromium.org> References: <20180927004810.124185-1-mka@chromium.org> <20180927004810.124185-2-mka@chromium.org> Message-ID: X-Sender: bgodavar@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matthias, On 2018-09-27 06:18, Matthias Kaehlcke wrote: > Provide an API for Bluetooth drivers to retrieve the Bluetooth Device > address (BD_ADDR) for a device. If the firmware node of the device > has a property 'local-bd-address' the BD address is read from this > property. > > Signed-off-by: Matthias Kaehlcke > Reviewed-by: Andy Shevchenko > Reviewed-by: Sakari Ailus > --- > Changes in v4: > - move code from driver/base/property.c to net/bluetooth/lib.c > - undo move of bdaddr_t declaration > - merge fwnode_get_bd_address() into device_get_bd_address(). as of now > the function is not needed, it can be created later if necessary > - minor improvements suggested by Sakari > - updated commit message > - added 'Reviewed-by: Sakari Ailus ' tag > > Changes in v3: > - move definition of bdaddr_t to types.h to avoid include of > bluetooth.h from property.h > - add stubs for the new functions > > Changes in v2: > - use bdaddr_t instead of byte pointer + len > - use EXPORT_SYMBOL_GPL for the new functions instead of EXPORT_SYMBOL > - put new functions inside #if IS_ENABLED(CONFIG_BT) > - some new line juggling in property.h > - added 'Reviewed-by: Andy Shevchenko ' tag > --- > include/net/bluetooth/bluetooth.h | 2 ++ > net/bluetooth/lib.c | 34 +++++++++++++++++++++++++++++++ > 2 files changed, 36 insertions(+) > > diff --git a/include/net/bluetooth/bluetooth.h > b/include/net/bluetooth/bluetooth.h > index ec9d6bc65855..6c4cecfda816 100644 > --- a/include/net/bluetooth/bluetooth.h > +++ b/include/net/bluetooth/bluetooth.h > @@ -413,4 +413,6 @@ void mgmt_exit(void); > > void bt_sock_reclassify_lock(struct sock *sk, int proto); > > +int device_get_bd_address(struct device *dev, bdaddr_t *bd_addr); > + > #endif /* __BLUETOOTH_H */ > diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c > index 63e65d9b4b24..78a58ea586c6 100644 > --- a/net/bluetooth/lib.c > +++ b/net/bluetooth/lib.c > @@ -26,7 +26,10 @@ > > #define pr_fmt(fmt) "Bluetooth: " fmt > > +#include > #include > +#include > +#include > > #include > > @@ -198,3 +201,34 @@ void bt_err_ratelimited(const char *format, ...) > va_end(args); > } > EXPORT_SYMBOL(bt_err_ratelimited); > + > +/** > + * device_get_bd_address - Get the Bluetooth Device Address (BD_ADDR) > for a > + * given device > + * @dev: Pointer to the device > + * @bd_addr: Pointer to struct to store the BD address in > + * > + * Search the firmware node of the device for 'local-bd-address'. > + * > + * All-zero BD addresses are rejected, because those could be > properties > + * that exist in the firmware tables, but were not updated by the > firmware. For > + * example, the DTS could define 'local-bd-address', with zero BD > addresses. > + */ > +int device_get_bd_address(struct device *dev, bdaddr_t *bd_addr) > +{ > + struct fwnode_handle *fwnode = dev_fwnode(dev); > + bdaddr_t ba; > + int ret; > + > + ret = fwnode_property_read_u8_array(fwnode, "local-bd-address", > + (u8 *)&ba, sizeof(ba)); > + if (ret < 0) > + return ret; > + if (is_zero_ether_addr((u8 *)&ba)) > + return -ENODATA; > + > + *bd_addr = ba; > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(device_get_bd_address); Reviewed-by: Balakrishna Godavarthi -- Regards Balakrishna.