rt2x00: allow overriding eeprom through platform_data
PATCH 1/3 rt2x00: allow overriding eeprom through platform_data
create mode 100644 drivers/net/wireless/rt2x00/rt2x00eeprom.c create mode 100644 include/linux/rt2x00_platform.h
drivers/net/wireless/rt2x00/Kconfig +4 -0
@@ -60,6 +60,7 @@ config RT2800PCI select RT2X00_LIB_PCI if PCI select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X select RT2X00_LIB_FIRMWARE + select RT2X00_LIB_EEPROM select RT2X00_LIB_CRYPTO select CRC_CCITT select EEPROM_93CX6
@@ -212,6 +213,9 @@ config RT2X00_LIB_FIRMWARE config RT2X00_LIB_CRYPTO boolean +config RT2X00_LIB_EEPROM + boolean + config RT2X00_LIB_LEDS boolean default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)
drivers/net/wireless/rt2x00/Makefile +1 -0
@@ -7,6 +7,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) += rt2x00debug.o rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o +rt2x00lib-$(CONFIG_RT2X00_LIB_EEPROM) += rt2x00eeprom.o obj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.o
drivers/net/wireless/rt2x00/rt2800pci.c +20 -14
@@ -89,20 +89,10 @@ static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token)rt2x00pci_register_write (rt2x00dev,H2M_MAILBOX_CID , ~0 ); } -#if defined(CONFIG_RALINK_RT288X ) || defined(CONFIG_RALINK_RT305X ) -static void rt2800pci_read_eeprom_soc (struct rt2x00_dev *rt2x00dev) -{ -void __iomem *base_addr =ioremap (0x1F040000 ,EEPROM_SIZE ); - -memcpy_fromio (rt2x00dev->eeprom, base_addr,EEPROM_SIZE ); - -iounmap (base_addr); -} -#else -static inline void rt2800pci_read_eeprom_soc (struct rt2x00_dev *rt2x00dev) +static void rt2800pci_read_eeprom_file (struct rt2x00_dev *rt2x00dev) { +memcpy (rt2x00dev->eeprom, rt2x00dev->eeprom_file->data,EEPROM_SIZE ); } -#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */ #ifdef CONFIG_PCI static void rt2800pci_eepromregister_read (struct eeprom_93cx6 *eeprom)
@@ -322,6 +312,20 @@ static int rt2800pci_write_firmware(struct rt2x00_dev *rt2x00dev, }/* +* EEPROM file functions. +*/ +static char *rt2800pci_get_eeprom_file_name (struct rt2x00_dev *rt2x00dev) +{ +struct rt2x00_platform_data *pdata; + + pdata = rt2x00dev->dev->platform_data; +if (pdata) +return pdata->eeprom_file_name; + +return NULL ; +} + +/* * Initialization functions. */ static bool rt2800pci_get_entry_state (struct queue_entry *entry)
@@ -972,8 +976,9 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance)*/ static void rt2800pci_read_eeprom (struct rt2x00_dev *rt2x00dev) { -if (rt2x00_is_soc (rt2x00dev)) -rt2800pci_read_eeprom_soc (rt2x00dev); +if (rt2x00_is_soc (rt2x00dev) || +test_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags)) +rt2800pci_read_eeprom_file (rt2x00dev);else if (rt2800pci_efuse_detect (rt2x00dev))rt2800pci_read_eeprom_efuse (rt2x00dev);else
@@ -1033,6 +1038,7 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { .get_firmware_name = rt2800pci_get_firmware_name, .check_firmware = rt2800_check_firmware, .load_firmware = rt2800_load_firmware, + .get_eeprom_file_name = rt2800pci_get_eeprom_file_name, .initialize = rt2x00pci_initialize, .uninitialize = rt2x00pci_uninitialize, .get_entry_state = rt2800pci_get_entry_state,
drivers/net/wireless/rt2x00/rt2x00.h +8 -0
@@ -39,6 +39,7 @@#include <linux/input-polldev.h> #include <linux/kfifo.h> #include <linux/hrtimer.h> +#include <linux/rt2x00_platform.h> #include <net/mac80211.h>
@@ -560,6 +561,7 @@ struct rt2x00lib_ops { const u8 *data, const size_t len);int (*load_firmware) (struct rt2x00_dev *rt2x00dev,const u8 *data,const size_t len); +char *(*get_eeprom_file_name) (struct rt2x00_dev *rt2x00dev);/* * Device initialization/deinitialization handlers.
@@ -720,6 +722,7 @@ enum rt2x00_capability_flags {REQUIRE_SW_SEQNO ,REQUIRE_HT_TX_DESC ,REQUIRE_PS_AUTOWAKE , + REQUIRE_EEPROM_FILE,/* * Capabilities
@@ -989,6 +992,11 @@ struct rt2x00_dev {const struct firmware *fw;/* +* EEPROM image. +*/ +const struct firmware *eeprom_file; + +/* * FIFO for storing tx status reports between isr and tasklet. */ DECLARE_KFIFO_PTR (txstatus_fifo, u32);
drivers/net/wireless/rt2x00/rt2x00dev.c +9 -0
@@ -1207,6 +1207,10 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) rt2x00dev->hw->wiphy->flags |=WIPHY_FLAG_IBSS_RSN ; + retval =rt2x00lib_load_eeprom_file (rt2x00dev); +if (retval) + goto exit; +/* * Initialize work. */
@@ -1331,6 +1335,11 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)*/ if (rt2x00dev->drv_data)kfree (rt2x00dev->drv_data); + +/* +* Free EEPROM image. +*/ +rt2x00lib_free_eeprom_file (rt2x00dev); }EXPORT_SYMBOL_GPL (rt2x00lib_remove_dev);
drivers/net/wireless/rt2x00/rt2x00eeprom.c new file +98 -0
98 lines not on this page · raw message
drivers/net/wireless/rt2x00/rt2x00lib.h +16 -0
@@ -322,6 +322,22 @@ static inline void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev)#endif /* CONFIG_RT2X00_LIB_FIRMWARE */ /* +* EEPROM file handlers. +*/ +#ifdef CONFIG_RT2X00_LIB_EEPROM +int rt2x00lib_load_eeprom_file (struct rt2x00_dev *rt2x00dev); +void rt2x00lib_free_eeprom_file (struct rt2x00_dev *rt2x00dev); +#else +static inline int rt2x00lib_load_eeprom_file (struct rt2x00_dev *rt2x00dev) +{ +return 0 ; +} +static inline void rt2x00lib_free_eeprom_file (struct rt2x00_dev *rt2x00dev) +{ +} +#endif /* CONFIG_RT2X00_LIB_EEPROM_FILE */ + +/* * Debugfs handlers. */ #ifdef CONFIG_RT2X00_LIB_DEBUGFS
drivers/net/wireless/rt2x00/rt2x00pci.c +7 -0
@@ -254,6 +254,7 @@ exit:int rt2x00pci_probe (struct pci_dev *pci_dev,const struct rt2x00_ops *ops) {struct ieee80211_hw *hw; +struct rt2x00_platform_data *pdata;struct rt2x00_dev *rt2x00dev;int retval;u16 chip;
@@ -297,6 +298,12 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops) rt2x00dev->irq = pci_dev->irq; rt2x00dev->name =pci_name (pci_dev); +/* if we get passed the name of a eeprom_file_name, then use this in +favour of the eeprom */ + pdata = rt2x00dev->dev->platform_data; +if (pdata && pdata->eeprom_file_name) +set_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags); +if (pci_is_pcie (pci_dev))rt2x00_set_chip_intf (rt2x00dev,RT2X00_CHIP_INTF_PCIE );else
drivers/net/wireless/rt2x00/rt2x00soc.c +1 -0
@@ -94,6 +94,7 @@ int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x00_ops *ops) rt2x00dev->hw = hw; rt2x00dev->irq =platform_get_irq (pdev,0 ); rt2x00dev->name = pdev->dev.driver->name; +set_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags);rt2x00_set_chip_intf (rt2x00dev,RT2X00_CHIP_INTF_SOC );
include/linux/rt2x00_platform.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* Platform data definition for the rt2x00 driver +* +* Copyright (C) 2011 Gabor Juhos <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +*/ + +#ifndef _RT2X00_PLATFORM_H +#define _RT2X00_PLATFORM_H + +struct rt2x00_platform_data { +char *eeprom_file_name; +}; + +#endif /* _RT2X00_PLATFORM_H */
Signature · 1 line
1.8.0.1
Hi Daniel,
Quoted 2 lines · Daniel Golle
Signed-off-by Daniel Golle <[email protected]>
We really need a proper patch description, explaining why the patch is needed. You explained in the intro [0 / 3], but that one isn't committed to git. So, to have some proper information in the git log we need the info included in the patch itself.
See also below for some concerns on the changes themselves.
Quoted 23 lines
create mode 100644
drivers/net/wireless/rt2x00/rt2x00eeprom.ccreate mode 100644include/linux/rt2x00_platform.hdrivers/net/wireless/rt2x00/Kconfig +1
-0@@ -60,6 +60,7 @@ config RT2800PCI select RT2X00_LIB_PCI if PCI select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X select RT2X00_LIB_FIRMWARE + select RT2X00_LIB_EEPROM select RT2X00_LIB_CRYPTO select CRC_CCITT select EEPROM_93CX6@@ -212,6 +213,9 @@ config RT2X00_LIB_FIRMWAREconfig
RT2X00_LIB_CRYPTO
booleandrivers/net/wireless/rt2x00/Kconfig +3
-0+config RT2X00_LIB_EEPROM + boolean +
Quoted 3 lines
config
RT2X00_LIB_LEDS
boolean
default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)
I find the approach very complicated, with all the general facilities that are only used by rt2800. Why not read the eeprom file directly from rt2800pci.c, with an directly coded call to request_firmware, instead of reading it at another place and then only copying it later.
Quoted 26 lines
drivers/net/wireless/rt2x00/Makefile +0
-0@@ -7,6 +7,7 @@ rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) += rt2x00debug.ort2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o
rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o
rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o
+rt2x00lib-$(CONFIG_RT2X00_LIB_EEPROM) += rt2x00eeprom.oobj-$(CONFIG_RT2X00_LIB) += rt2x00lib.o
obj-$(CONFIG_RT2X00_LIB_PCI) += rt2x00pci.odrivers/net/wireless/rt2x00/rt2800pci.c +0
-6@@ -89,20 +89,10 @@ static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token)rt2x00pci_register_write (rt2x00dev,H2M_MAILBOX_CID , ~0 ); } -#if defined(CONFIG_RALINK_RT288X ) || defined(CONFIG_RALINK_RT305X ) -static void rt2800pci_read_eeprom_soc (struct rt2x00_dev *rt2x00dev) -{ -void __iomem *base_addr =ioremap (0x1F040000 ,EEPROM_SIZE ); - -memcpy_fromio (rt2x00dev->eeprom, base_addr,EEPROM_SIZE );
drivers/net/wireless/rt2x00/rt2800pci.c static void rt2800pci_mcu_status(struct rt2x00_dev *rt2x00dev, const u8 token) · line 105
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +2
-6- - iounmap(base_addr); -} -#else -static inline void rt2800pci_read_eeprom_soc (struct rt2x00_dev *rt2x00dev) +static void rt2800pci_read_eeprom_file (struct rt2x00_dev *rt2x00dev) { +memcpy (rt2x00dev->eeprom, rt2x00dev->eeprom_file->data,EEPROM_SIZE ); } -#endif /* CONFIG_RALINK_RT288X || CONFIG_RALINK_RT305X */
I meant with the previous comment to read the file right here, instead of at a different place in the code.
Quoted 11 lines
drivers/net/wireless/rt2x00/rt2800pci.c +4
-0#ifdef CONFIG_PCI static void rt2800pci_eepromregister_read (struct eeprom_93cx6 *eeprom)@@ -322,6 +312,20 @@ static int rt2800pci_write_firmware(struct rt2x00_dev *rt2x00dev, }/* +* EEPROM file functions. +*/ +static char *rt2800pci_get_eeprom_file_name (struct rt2x00_dev *rt2x00dev) +{
drivers/net/wireless/rt2x00/rt2800pci.c static int rt2800pci_write_firmware(struct rt2x00_dev *rt2x00dev, · line 328
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2800pci.c +10
-0+struct rt2x00_platform_data *pdata; + + pdata = rt2x00dev->dev->platform_data; +if (pdata) +return pdata->eeprom_file_name; + +return NULL ; +} + +/*
That would make this redundant.
Quoted 16 lines
drivers/net/wireless/rt2x00/rt2800pci.c +3
-2* Initialization functions. */ static bool rt2800pci_get_entry_state (struct queue_entry *entry)@@ -972,8 +976,9 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance)*/ static void rt2800pci_read_eeprom (struct rt2x00_dev *rt2x00dev) { -if (rt2x00_is_soc (rt2x00dev)) -rt2800pci_read_eeprom_soc (rt2x00dev); +if (rt2x00_is_soc (rt2x00dev) || +test_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags)) +rt2800pci_read_eeprom_file (rt2x00dev);else if (rt2800pci_efuse_detect (rt2x00dev))rt2800pci_read_eeprom_efuse (rt2x00dev);else
drivers/net/wireless/rt2x00/rt2800pci.c static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { · line 1044
Quoted 7 lines
drivers/net/wireless/rt2x00/rt2800pci.c +1
-0@@ -1033,6 +1038,7 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { .get_firmware_name = rt2800pci_get_firmware_name, .check_firmware = rt2800_check_firmware, .load_firmware = rt2800_load_firmware, + .get_eeprom_file_name = rt2800pci_get_eeprom_file_name, .initialize = rt2x00pci_initialize, .uninitialize = rt2x00pci_uninitialize, .get_entry_state = rt2800pci_get_entry_state,
And this part as well.
Quoted 30 lines
drivers/net/wireless/rt2x00/rt2x00.h +3
-0@@ -39,6 +39,7 @@#include <linux/input-polldev.h> #include <linux/kfifo.h> #include <linux/hrtimer.h> +#include <linux/rt2x00_platform.h> #include <net/mac80211.h> @@ -560,6 +561,7 @@ struct rt2x00lib_ops { const u8 *data, const size_t len);int (*load_firmware) (struct rt2x00_dev *rt2x00dev,const u8 *data,const size_t len); +char *(*get_eeprom_file_name) (struct rt2x00_dev *rt2x00dev);/* * Device initialization/deinitialization handlers. @@ -720,6 +722,7 @@ enum rt2x00_capability_flags {REQUIRE_SW_SEQNO ,REQUIRE_HT_TX_DESC ,REQUIRE_PS_AUTOWAKE , + REQUIRE_EEPROM_FILE,/* * Capabilities @@ -989,6 +992,11 @@ struct rt2x00_dev {const struct firmware *fw;
drivers/net/wireless/rt2x00/rt2x00.h struct rt2x00_dev { · line 1002
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2x00.h +5
-0/* +* EEPROM image. +*/ +const struct firmware *eeprom_file; + +/* * FIFO for storing tx status reports between isr and tasklet. */ DECLARE_KFIFO_PTR (txstatus_fifo, u32);
And this would not be needed at all, as the struct firmware could be local to the firmware reading function.
Quoted 76 lines
drivers/net/wireless/rt2x00/rt2x00dev.c +9
-0@@ -1207,6 +1207,10 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) rt2x00dev->hw->wiphy->flags |=WIPHY_FLAG_IBSS_RSN ; + retval =rt2x00lib_load_eeprom_file (rt2x00dev); +if (retval) + goto exit; +/* * Initialize work. */ @@ -1331,6 +1335,11 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev)*/ if (rt2x00dev->drv_data)kfree (rt2x00dev->drv_data); + +/* +* Free EEPROM image. +*/ +rt2x00lib_free_eeprom_file (rt2x00dev); }EXPORT_SYMBOL_GPL (rt2x00lib_remove_dev);drivers/net/wireless/rt2x00/rt2x00eeprom.c new file +43
-0@@ -0,0 +1,98 @@ +/* +Copyright (C) 2004 - 2009 Ivo van Doorn <[email protected]> +Copyright (C) 2004 - 2009 Gertjan van Wingerde <[email protected]> +<http://rt2x00.serialmonkey.com> + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the +Free Software Foundation, Inc., +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/* +Module: rt2x00lib +Abstract: rt2x00 eeprom file loading routines. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> + +#include "rt2x00.h" +#include "rt2x00lib.h" + +static int rt2x00lib_request_eeprom_file (struct rt2x00_dev *rt2x00dev) +{ +const struct firmware *ee; +char *ee_name; +int retval; + + ee_name = rt2x00dev->ops->lib->get_eeprom_file_name (rt2x00dev); +if (!ee_name) { +ERROR (rt2x00dev, +"Invalid EEPROM filename.\n" +"Please file bug report to %s.\n" ,DRV_PROJECT );
drivers/net/wireless/rt2x00/rt2x00eeprom.c line 53
Quoted 10 lines
drivers/net/wireless/rt2x00/rt2x00eeprom.c new file +10
-0+return -EINVAL ; + } + +INFO (rt2x00dev,"Loading EEPROM data from '%s'.\n" , ee_name); + + retval =request_firmware (&ee, ee_name, rt2x00dev->dev); +if (retval) { +ERROR (rt2x00dev,"Failed to request EEPROM.\n" ); +return retval; + }
And here is the biggest problem of this patch. Request_firmware is synchronous and will fail when userspace isn't up yet. For built-in versions of the driver userspace isn't up yet at this point of time, so this will fail then.
Quoted 137 lines
drivers/net/wireless/rt2x00/rt2x00eeprom.c new file +45
-0+ +if (!ee || !ee->size || !ee->data) { +ERROR (rt2x00dev,"Failed to read EEPROM file.\n" ); + retval = -ENOENT ; + goto err_exit; + } + +if (ee->size != rt2x00dev->ops->eeprom_size) { +ERROR (rt2x00dev, +"EEPROM file size is invalid, it should be %d bytes\n" , + rt2x00dev->ops->eeprom_size); + retval = -EINVAL ; + goto err_release_ee; + } + + rt2x00dev->eeprom_file = ee; +return 0 ; + +err_release_ee: +release_firmware (ee); +err_exit: +return retval; +} + +int rt2x00lib_load_eeprom_file (struct rt2x00_dev *rt2x00dev) +{ +int retval; + +if (!test_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags)) +return 0 ; + +if (!rt2x00dev->eeprom_file) { + retval =rt2x00lib_request_eeprom_file (rt2x00dev); +if (retval) +return retval; + } + +return 0 ; +} + +void rt2x00lib_free_eeprom_file (struct rt2x00_dev *rt2x00dev) +{ +release_firmware (rt2x00dev->eeprom_file); + rt2x00dev->eeprom_file =NULL ; +}drivers/net/wireless/rt2x00/rt2x00lib.h +16
-0@@ -322,6 +322,22 @@ static inline void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev)#endif /* CONFIG_RT2X00_LIB_FIRMWARE */ /* +* EEPROM file handlers. +*/ +#ifdef CONFIG_RT2X00_LIB_EEPROM +int rt2x00lib_load_eeprom_file (struct rt2x00_dev *rt2x00dev); +void rt2x00lib_free_eeprom_file (struct rt2x00_dev *rt2x00dev); +#else +static inline int rt2x00lib_load_eeprom_file (struct rt2x00_dev *rt2x00dev) +{ +return 0 ; +} +static inline void rt2x00lib_free_eeprom_file (struct rt2x00_dev *rt2x00dev) +{ +} +#endif /* CONFIG_RT2X00_LIB_EEPROM_FILE */ + +/* * Debugfs handlers. */ #ifdef CONFIG_RT2X00_LIB_DEBUGFS drivers/net/wireless/rt2x00/rt2x00pci.c +7
-0@@ -254,6 +254,7 @@ exit:int rt2x00pci_probe (struct pci_dev *pci_dev,const struct rt2x00_ops *ops) {struct ieee80211_hw *hw; +struct rt2x00_platform_data *pdata;struct rt2x00_dev *rt2x00dev;int retval;u16 chip;@@ -297,6 +298,12 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct rt2x00_ops *ops) rt2x00dev->irq = pci_dev->irq; rt2x00dev->name =pci_name (pci_dev); +/* if we get passed the name of a eeprom_file_name, then use this in +favour of the eeprom */ + pdata = rt2x00dev->dev->platform_data; +if (pdata && pdata->eeprom_file_name) +set_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags); +if (pci_is_pcie (pci_dev))rt2x00_set_chip_intf (rt2x00dev,RT2X00_CHIP_INTF_PCIE );else drivers/net/wireless/rt2x00/rt2x00soc.c +1
-0@@ -94,6 +94,7 @@ int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x00_ops *ops) rt2x00dev->hw = hw; rt2x00dev->irq =platform_get_irq (pdev,0 ); rt2x00dev->name = pdev->dev.driver->name; +set_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags);rt2x00_set_chip_intf (rt2x00dev,RT2X00_CHIP_INTF_SOC );include/linux/rt2x00_platform.h new file +19
-0@@ -0,0 +1,19 @@ +/* +* Platform data definition for the rt2x00 driver +* +* Copyright (C) 2011 Gabor Juhos <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published +* by the Free Software Foundation. +* +*/ + +#ifndef _RT2X00_PLATFORM_H +#define _RT2X00_PLATFORM_H + +struct rt2x00_platform_data { +char *eeprom_file_name; +}; + +#endif /* _RT2X00_PLATFORM_H */ Signature · 1 line
1.8.0.1
2012.12.11. 22:40 keltezéssel, Gertjan van Wingerde írta:
Quoted 32 lines
Hi Daniel,
Quoted 2 lines · Daniel Golle
Signed-off-by Daniel Golle <[email protected]>We really need a proper patch description, explaining why the patch is needed. You explained in the intro [0 / 3], but that one isn't committed to git. So, to have some proper information in the git log we need the info included in the patch itself.
See also below for some concerns on the changes themselves.
Quoted 20 lines
create mode 100644
drivers/net/wireless/rt2x00/rt2x00eeprom.ccreate mode 100644include/linux/rt2x00_platform.hdrivers/net/wireless/rt2x00/Kconfig +1
-0@@ -60,6 +60,7 @@ config RT2800PCI select RT2X00_LIB_PCI if PCI select RT2X00_LIB_SOC if RALINK_RT288X || RALINK_RT305X select RT2X00_LIB_FIRMWARE + select RT2X00_LIB_EEPROM select RT2X00_LIB_CRYPTO select CRC_CCITT select EEPROM_93CX6@@ -212,6 +213,9 @@ config RT2X00_LIB_FIRMWAREconfig
RT2X00_LIB_CRYPTO
boolean
Quoted 9 lines
Quoted 6 lines
drivers/net/wireless/rt2x00/Kconfig +3
-0+config RT2X00_LIB_EEPROM + boolean +config
RT2X00_LIB_LEDS
boolean
default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n)I find the approach very complicated, with all the general facilities that are only used by rt2800.
The idea behind the generic approach was that the feature can be used for EEPROM-less rt2500/rt61 based PCI devices as well. However I did not find any such device yet, so the rt2500/rt61 part was never implemented.
Quoted 3 lines
Why not read the eeprom file directly from
rt2800pci.c, with an directly coded call torequest_firmware, instead of reading it at another place and then only copying it later.
You are right, things would be much simpler this way. If someone ever encounter a board with a rt2500/rt61 chip which needs this feature, the generalization can happen later.
<...>
Quoted 8 lines
Quoted 5 lines
+static void
rt2800pci_read_eeprom_file(struct rt2x00_dev *rt2x00dev){
+memcpy(rt2x00dev->eeprom, rt2x00dev->eeprom_file->data, EEPROM_SIZE);
}
-#endif /*CONFIG_RALINK_RT288X||CONFIG_RALINK_RT305X*/I meant with the previous comment to read the file right here, instead of at a different place in the code.
True.
Quoted 14 lines
Quoted 14 lines
#ifdef
CONFIG_PCI
static voidrt2800pci_eepromregister_read(struct eeprom_93cx6 *eeprom)drivers/net/wireless/rt2x00/Kconfig +8
-0@@ -322,6 +312,20 @@ static int rt2800pci_write_firmware(struct rt2x00_dev *rt2x00dev, } /* + * EEPROM file functions. + */ +static char *rt2800pci_get_eeprom_file_name(struct rt2x00_dev *rt2x00dev) +{ + struct rt2x00_platform_data *pdata; + + pdata = rt2x00dev->dev->platform_data; + if (pdata)
Quoted 8 lines
drivers/net/wireless/rt2x00/Kconfig static int rt2800pci_write_firmware(struct rt2x00_dev *rt2x00dev, · line 328
Quoted 6 lines
drivers/net/wireless/rt2x00/Kconfig +6
-0+ return pdata->eeprom_file_name; + + return NULL; +} + +/*That would make this redundant.
Yes.
Quoted 18 lines
Quoted 18 lines
drivers/net/wireless/rt2x00/Kconfig +3
-2* Initialization functions. */ static bool rt2800pci_get_entry_state(struct queue_entry *entry)@@ -972,8 +976,9 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) */ static void rt2800pci_read_eeprom(struct rt2x00_dev *rt2x00dev) { - if (rt2x00_is_soc(rt2x00dev)) - rt2800pci_read_eeprom_soc(rt2x00dev); + if (rt2x00_is_soc(rt2x00dev) || + test_bit(REQUIRE_EEPROM_FILE, &rt2x00dev->cap_flags)) + rt2800pci_read_eeprom_file(rt2x00dev); else if (rt2800pci_efuse_detect(rt2x00dev)) rt2800pci_read_eeprom_efuse(rt2x00dev); else@@ -1033,6 +1038,7 @@ static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { .get_firmware_name = rt2800pci_get_firmware_name,
Quoted 8 lines
drivers/net/wireless/rt2x00/Kconfig static const struct rt2x00lib_ops rt2800pci_rt2x00_ops = { · line 1044
Quoted 6 lines
drivers/net/wireless/rt2x00/Kconfig +1
-0.check_firmware = rt2800_check_firmware, .load_firmware = rt2800_load_firmware, + .get_eeprom_file_name = rt2800pci_get_eeprom_file_name, .initialize = rt2x00pci_initialize, .uninitialize = rt2x00pci_uninitialize, .get_entry_state = rt2800pci_get_entry_state,And this part as well.
Yes.
<...>
Quoted 15 lines
drivers/net/wireless/rt2x00/Kconfig struct rt2x00_dev { · line 1002
Quoted 12 lines
drivers/net/wireless/rt2x00/Kconfig +5
-0@@ -989,6 +992,11 @@ struct rt2x00_dev { const struct firmware *fw; /* + * EEPROM image. + */ + const struct firmware *eeprom_file; + + /* * FIFO for storing tx status reports between isr and tasklet. */ DECLARE_KFIFO_PTR(txstatus_fifo, u32);And this would not be needed at all, as the struct firmware could be local to the firmware reading function.
Ok.
<...>
Quoted 18 lines
Quoted 18 lines
drivers/net/wireless/rt2x00/Kconfig +18
-0+static int rt2x00lib_request_eeprom_file(struct rt2x00_dev *rt2x00dev) +{ + const struct firmware *ee; + char *ee_name; + int retval; + + ee_name = rt2x00dev->ops->lib->get_eeprom_file_name(rt2x00dev); + if (!ee_name) { + ERROR(rt2x00dev, + "Invalid EEPROM filename.\n" + "Please file bug report to %s.\n", DRV_PROJECT); + return -EINVAL; + } + + INFO(rt2x00dev, "Loading EEPROM data from '%s'.\n", ee_name); + + retval = request_firmware(&ee, ee_name, rt2x00dev->dev); + if (retval) {
Quoted 8 lines
drivers/net/wireless/rt2x00/Kconfig
Quoted 3 lines
drivers/net/wireless/rt2x00/Kconfig +3
-0+ ERROR(rt2x00dev, "Failed to request EEPROM.\n"); + return retval; + }And here is the biggest problem of this patch.
Request_firmwareis synchronous and will fail when userspace isn't up yet. For built-in versions of the driver userspace isn't up yet at this point of time, so this will fail then.
Yes, this should be asynchronous. The original patch was developed two years ago and I was not aware of the asynchronous version of request_firmware at that time. Because OpenWrt uses the compat-wireless package so the driver is always loaded as a module, I did not bother to change this.
Thank you for the review!
-Gabor
Hi
I have one additional question:
drivers/net/wireless/rt2x00/rt2800pci.c static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) · line 981
Quoted 3 lines · Daniel Golle
drivers/net/wireless/rt2x00/rt2800pci.c +3
-0+if (rt2x00_is_soc (rt2x00dev) || +test_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags)) +rt2800pci_read_eeprom_file (rt2x00dev);
Is || correct here ?
Stanislaw
2012.12.12. 8:36 keltezéssel, Stanislaw Gruszka írta:
Quoted 9 lines
Hi
I have one additional question:
drivers/net/wireless/rt2x00/rt2800pci.c static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) · line 981
Quoted 3 lines · Daniel Golle
drivers/net/wireless/rt2x00/rt2800pci.c +3
-0+if (rt2x00_is_soc (rt2x00dev) || +test_bit (REQUIRE_EEPROM_FILE , &rt2x00dev->cap_flags)) +rt2800pci_read_eeprom_file (rt2x00dev);Is || correct here ?
There are various embedded boards where a Ralink WiFi chip is soldered directly onto the PCB and that does not have a separate EEPROM. The EEPROM data is stored in the main flash of the board. The '||' allows to load the EEPROM data via firmware API for such PCI devices as well.
However, the condition can be simplified. The REQUIRE_EEPROM_FILE bit is always set for SoC devices, so the 'rt2x00_is_soc(rt2x00dev) ||' part is superfluous.
Given the fact that the patch must be reworked, this part will go away anyway probably.
-Gabor