linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: Felix Fietkau <nbd@openwrt.org>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH v2 1/2] mt76: add common code shared between multiple chipsets
Date: Tue, 26 Apr 2016 11:43:19 +0300	[thread overview]
Message-ID: <87potczro8.fsf@kamboji.qca.qualcomm.com> (raw)
In-Reply-To: <1457039737-61262-1-git-send-email-nbd@openwrt.org> (Felix Fietkau's message of "Thu, 3 Mar 2016 22:15:36 +0100")

Felix Fietkau <nbd@openwrt.org> writes:

> This will be used by drivers for MT76x2e, MT7603e and MT7628
>
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>

[...]

> +static int
> +mt76_get_of_eeprom(struct mt76_dev *dev, int len)
> +{
> +#ifdef CONFIG_OF
> +	struct device_node *np = dev->dev->of_node;
> +	struct mtd_info *mtd;
> +	const __be32 *list;
> +	const char *part;
> +	phandle phandle;
> +	int offset = 0;
> +	int size;
> +	size_t retlen;
> +	int ret;
> +
> +	if (!np)
> +		return -ENOENT;
> +
> +	list = of_get_property(np, "mediatek,mtd-eeprom", &size);
> +	if (!list)
> +		return -ENOENT;
> +
> +	phandle = be32_to_cpup(list++);
> +	if (!phandle)
> +		return -ENOENT;
> +
> +	np = of_find_node_by_phandle(phandle);
> +	if (!np)
> +		return -EINVAL;
> +
> +	part = of_get_property(np, "label", NULL);
> +	if (!part)
> +		part = np->name;
> +
> +	mtd = get_mtd_device_nm(part);
> +	if (IS_ERR(mtd))
> +		return PTR_ERR(mtd);
> +
> +	if (size <= sizeof(*list))
> +		return -EINVAL;
> +
> +	offset = be32_to_cpup(list);
> +	ret = mtd_read(mtd, offset, len, &retlen, dev->eeprom.data);
> +	put_mtd_device(mtd);
> +	if (ret)
> +		return ret;
> +
> +	if (retlen < len)
> +		return -EINVAL;
> +
> +	return 0;
> +#else
> +	return -ENOENT;
> +#endif
> +}
> +
> +void
> +mt76_eeprom_override(struct mt76_dev *dev)
> +{
> +#ifdef CONFIG_OF
> +	struct device_node *np = dev->dev->of_node;
> +	const __be32 *val;
> +	const u8 *mac;
> +	int size;
> +
> +	if (!np)
> +		return;
> +
> +	val = of_get_property(np, "mediatek,2ghz", &size);
> +	if (val)
> +		dev->cap.has_2ghz = be32_to_cpup(val);
> +
> +	val = of_get_property(np, "mediatek,5ghz", &size);
> +	if (val)
> +		dev->cap.has_5ghz = be32_to_cpup(val);
> +
> +	mac = of_get_mac_address(np);
> +	if (mac)
> +		memcpy(dev->macaddr, mac, ETH_ALEN);
> +#endif

All device tree properties need a binding document in
Documentation/devicetree/bindings/ which will be reviewed by the device
tree maintainers.

> +MODULE_LICENSE("GPL");

"GPL v2"?

-- 
Kalle Valo

      parent reply	other threads:[~2016-04-26  8:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-03 21:15 [PATCH v2 1/2] mt76: add common code shared between multiple chipsets Felix Fietkau
2016-03-03 21:15 ` [PATCH v2 2/2] mt76: add driver code for MT76x2e Felix Fietkau
2016-04-26  8:46   ` Kalle Valo
2016-04-07 16:50 ` [PATCH v2 1/2] mt76: add common code shared between multiple chipsets Kalle Valo
2016-04-26  8:39   ` Kalle Valo
2016-04-26  8:43 ` Kalle Valo [this message]

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=87potczro8.fsf@kamboji.qca.qualcomm.com \
    --to=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@openwrt.org \
    /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;
as well as URLs for NNTP newsgroup(s).