Skip to content

Commit

Permalink
ath5k: Check if pci pdev struct is initialized in common functions.
Browse files Browse the repository at this point in the history
To be able to support other busses than PCI check if pci device
structure is initialized.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik@neratec.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Felix Fietkau authored and John W. Linville committed Dec 2, 2010
1 parent 4aa5d78 commit 8efa5d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions drivers/net/wireless/ath/ath5k/attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
/*
* Write PCI-E power save settings
*/
if ((ah->ah_version == AR5K_AR5212) && (pdev->is_pcie)) {
if ((ah->ah_version == AR5K_AR5212) && pdev && (pdev->is_pcie)) {
ath5k_hw_reg_write(ah, 0x9248fc00, AR5K_PCIE_SERDES);
ath5k_hw_reg_write(ah, 0x24924924, AR5K_PCIE_SERDES);

Expand Down Expand Up @@ -305,8 +305,7 @@ int ath5k_hw_init(struct ath5k_softc *sc)
/* Get misc capabilities */
ret = ath5k_hw_set_capabilities(ah);
if (ret) {
ATH5K_ERR(sc, "unable to get device capabilities: 0x%04x\n",
sc->pdev->device);
ATH5K_ERR(sc, "unable to get device capabilities\n");
goto err;
}

Expand Down
5 changes: 4 additions & 1 deletion drivers/net/wireless/ath/ath5k/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ ath5k_register_led(struct ath5k_softc *sc, struct ath5k_led *led,
led->led_dev.default_trigger = trigger;
led->led_dev.brightness_set = ath5k_led_brightness_set;

err = led_classdev_register(&sc->pdev->dev, &led->led_dev);
err = led_classdev_register(sc->dev, &led->led_dev);
if (err) {
ATH5K_WARN(sc, "could not register LED %s\n", name);
led->sc = NULL;
Expand Down Expand Up @@ -165,6 +165,9 @@ int ath5k_init_leds(struct ath5k_softc *sc)
char name[ATH5K_LED_MAX_NAME_LEN + 1];
const struct pci_device_id *match;

if (!sc->pdev)
return 0;

match = pci_match_id(&ath5k_led_devices[0], pdev);
if (match) {
__set_bit(ATH_STAT_LEDSOFT, sc->status);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath5k/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah)
* we ingore that flag for PCI-E cards. On PCI cards
* this flag gets cleared after 64 PCI clocks.
*/
bus_flags = (pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI;
bus_flags = (pdev && pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI;

if (ah->ah_version == AR5K_AR5210) {
ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
Expand Down Expand Up @@ -526,7 +526,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial)
* we ingore that flag for PCI-E cards. On PCI cards
* this flag gets cleared after 64 PCI clocks.
*/
bus_flags = (pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI;
bus_flags = (pdev && pdev->is_pcie) ? 0 : AR5K_RESET_CTL_PCI;

if (ah->ah_version == AR5K_AR5210) {
ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU |
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath/ath5k/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static struct attribute_group ath5k_attribute_group_ani = {
int
ath5k_sysfs_register(struct ath5k_softc *sc)
{
struct device *dev = &sc->pdev->dev;
struct device *dev = sc->dev;
int err;

err = sysfs_create_group(&dev->kobj, &ath5k_attribute_group_ani);
Expand All @@ -110,7 +110,7 @@ ath5k_sysfs_register(struct ath5k_softc *sc)
void
ath5k_sysfs_unregister(struct ath5k_softc *sc)
{
struct device *dev = &sc->pdev->dev;
struct device *dev = sc->dev;

sysfs_remove_group(&dev->kobj, &ath5k_attribute_group_ani);
}

0 comments on commit 8efa5d7

Please sign in to comment.