mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Golle <daniel@makrotopia.org>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Ryder Lee <ryder.lee@mediatek.com>,
	Shayne Chen <shayne.chen@mediatek.com>,
	Sean Wang <sean.wang@mediatek.com>, Kalle Valo <kvalo@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno 
	<angelogioacchino.delregno@collabora.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: Re: [PATCH 1/2] wifi: mt76: split get_of_eeprom in subfunction
Date: Thu, 13 Jul 2023 03:46:30 +0100	[thread overview]
Message-ID: <ZK9lhgH_sNmX3hWb@makrotopia.org> (raw)
In-Reply-To: <20230708182936.24469-1-ansuelsmth@gmail.com>

On Sat, Jul 08, 2023 at 08:29:35PM +0200, Christian Marangi wrote:
> In preparation for NVMEM support, split get_of_eeprom() in subfunction
> to tidy the code and facilitate the addition of alternative method to
> get eeprom data. No behaviour change intended.
> 
> While at it also drop OF ifdef checks as OF have stubs and calling
> of_get_property would result in the same error returned.
> 
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Tested-by: Daniel Golle <daniel@makrotopia.org>

> ---
>  drivers/net/wireless/mediatek/mt76/eeprom.c | 51 ++++++++++++++-------
>  1 file changed, 35 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c
> index dce851d42e08..c3a762074be8 100644
> --- a/drivers/net/wireless/mediatek/mt76/eeprom.c
> +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c
> @@ -9,31 +9,35 @@
>  #include <linux/etherdevice.h>
>  #include "mt76.h"
>  
> -int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
> +static int mt76_get_of_eeprom_data(struct mt76_dev *dev, void *eep, int len)
>  {
> -#if defined(CONFIG_OF) && defined(CONFIG_MTD)
>  	struct device_node *np = dev->dev->of_node;
> -	struct mtd_info *mtd;
> -	const __be32 *list;
>  	const void *data;
> -	const char *part;
> -	phandle phandle;
>  	int size;
> -	size_t retlen;
> -	int ret;
>  
> -	if (!np)
> +	data = of_get_property(np, "mediatek,eeprom-data", &size);
> +	if (!data)
>  		return -ENOENT;
>  
> -	data = of_get_property(np, "mediatek,eeprom-data", &size);
> -	if (data) {
> -		if (size > len)
> -			return -EINVAL;
> +	if (size > len)
> +		return -EINVAL;
>  
> -		memcpy(eep, data, size);
> +	memcpy(eep, data, size);
>  
> -		return 0;
> -	}
> +	return 0;
> +}
> +
> +static int mt76_get_of_epprom_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len)
> +{
> +#ifdef CONFIG_MTD
> +	struct device_node *np = dev->dev->of_node;
> +	struct mtd_info *mtd;
> +	const __be32 *list;
> +	const char *part;
> +	phandle phandle;
> +	size_t retlen;
> +	int size;
> +	int ret;
>  
>  	list = of_get_property(np, "mediatek,mtd-eeprom", &size);
>  	if (!list)
> @@ -100,6 +104,21 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
>  	return -ENOENT;
>  #endif
>  }
> +
> +int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len)
> +{
> +	struct device_node *np = dev->dev->of_node;
> +	int ret;
> +
> +	if (!np)
> +		return -ENOENT;
> +
> +	ret = mt76_get_of_eeprom_data(dev, eep, len);
> +	if (!ret)
> +		return 0;
> +
> +	return mt76_get_of_epprom_from_mtd(dev, eep, offset, len);
> +}
>  EXPORT_SYMBOL_GPL(mt76_get_of_eeprom);
>  
>  void
> -- 
> 2.40.1
> 
> 

  parent reply	other threads:[~2023-07-13  2:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-08 18:29 Christian Marangi
2023-07-08 18:29 ` [PATCH 2/2] wifi: mt76: add support for providing eeprom in nvmem cells Christian Marangi
2023-07-13  2:47   ` Daniel Golle
2023-07-28 17:45   ` Rafał Miłecki
2023-07-13  2:46 ` Daniel Golle [this message]
2023-07-28 17:45 ` [PATCH 1/2] wifi: mt76: split get_of_eeprom in subfunction Rafał Miłecki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZK9lhgH_sNmX3hWb@makrotopia.org \
    --to=daniel@makrotopia.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=ansuelsmth@gmail.com \
    --cc=kvalo@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=nbd@nbd.name \
    --cc=ryder.lee@mediatek.com \
    --cc=sean.wang@mediatek.com \
    --cc=shayne.chen@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®