static ssize_t b43legacy_debugfs_write(struct file *file, const char __user *userbuf, size_t count, loff_t *ppos) { struct b43legacy_wldev *dev; struct b43legacy_debugfs_fops *dfops; char *buf; int err = 0; if (!count) return 0; if (count > PAGE_SIZE) return -E2BIG; dev = file->private_data; if (!dev) return -ENODEV; mutex_lock(&dev->wl->mutex); if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) { err = -ENODEV; goto out_unlock; } dfops = container_of(file->f_op, struct b43legacy_debugfs_fops, fops); if (!dfops->write) { err = -ENOSYS; goto out_unlock; } buf = (char *)get_zeroed_page(GFP_KERNEL); if (!buf) { err = -ENOMEM; goto out_unlock; } if (copy_from_user(buf, userbuf, count)) { err = -EFAULT; goto out_freepage; } if (dfops->take_irqlock) { spin_lock_irq(&dev->wl->irq_lock); err = dfops->write(dev, buf, count); spin_unlock_irq(&dev->wl->irq_lock); } else err = dfops->write(dev, buf, count); if (err) goto out_freepage; out_freepage: free_page((unsigned long)buf); out_unlock: mutex_unlock(&dev->wl->mutex); return err ? err : count; }
bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev) { if (dev->phy.rev >= 3) { if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI) & B43legacy_MMIO_RADIO_HWENABLED_HI_MASK)) return 1; } else { if (b43legacy_status(dev) < B43legacy_STAT_STARTED) return 1; if (b43legacy_read16(dev, B43legacy_MMIO_RADIO_HWENABLED_LO) & B43legacy_MMIO_RADIO_HWENABLED_LO_MASK) return 1; } return 0; }
/* Returns TRUE, if the radio is enabled in hardware. */ bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev) { if (dev->phy.rev >= 3) { if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI) & B43legacy_MMIO_RADIO_HWENABLED_HI_MASK)) return 1; } else { /* To prevent CPU fault on PPC, do not read a register * unless the interface is started; however, on resume * for hibernation, this routine is entered early. When * that happens, unconditionally return TRUE. */ if (b43legacy_status(dev) < B43legacy_STAT_STARTED) return 1; if (b43legacy_read16(dev, B43legacy_MMIO_RADIO_HWENABLED_LO) & B43legacy_MMIO_RADIO_HWENABLED_LO_MASK) return 1; } return 0; }
int b43legacy_sysfs_register(struct b43legacy_wldev *wldev) { struct device *dev = wldev->dev->dev; int err; B43legacy_WARN_ON(b43legacy_status(wldev) != B43legacy_STAT_INITIALIZED); err = device_create_file(dev, &dev_attr_interference); if (err) goto out; err = device_create_file(dev, &dev_attr_shortpreamble); if (err) goto err_remove_interfmode; out: return err; err_remove_interfmode: device_remove_file(dev, &dev_attr_interference); goto out; }
void b43legacy_rfkill_poll(struct ieee80211_hw *hw) { struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw); struct b43legacy_wldev *dev = wl->current_dev; struct ssb_bus *bus = dev->dev->bus; bool enabled; bool brought_up = false; mutex_lock(&wl->mutex); if (unlikely(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)) { if (ssb_bus_powerup(bus, 0)) { mutex_unlock(&wl->mutex); return; } ssb_device_enable(dev->dev, 0); brought_up = true; } enabled = b43legacy_is_hw_radio_enabled(dev); if (unlikely(enabled != dev->radio_hw_enable)) { dev->radio_hw_enable = enabled; b43legacyinfo(wl, "Radio hardware status changed to %s\n", enabled ? "ENABLED" : "DISABLED"); wiphy_rfkill_set_hw_state(hw->wiphy, !enabled); if (enabled != dev->phy.radio_on) { if (enabled) b43legacy_radio_turn_on(dev); else b43legacy_radio_turn_off(dev, 0); } } if (brought_up) { ssb_device_disable(dev->dev, 0); ssb_bus_may_powerdown(bus); } mutex_unlock(&wl->mutex); }
static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) { struct b43legacy_wldev *dev; struct b43legacy_debugfs_fops *dfops; struct b43legacy_dfs_file *dfile; ssize_t uninitialized_var(ret); char *buf; const size_t bufsize = 1024 * 16; /* 16 KiB buffer */ const size_t buforder = get_order(bufsize); int err = 0; if (!count) return 0; dev = file->private_data; if (!dev) return -ENODEV; mutex_lock(&dev->wl->mutex); if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) { err = -ENODEV; goto out_unlock; } dfops = container_of(file->f_op, struct b43legacy_debugfs_fops, fops); if (!dfops->read) { err = -ENOSYS; goto out_unlock; } dfile = fops_to_dfs_file(dev, dfops); if (!dfile->buffer) { buf = (char *)__get_free_pages(GFP_KERNEL, buforder); if (!buf) { err = -ENOMEM; goto out_unlock; } memset(buf, 0, bufsize); if (dfops->take_irqlock) { spin_lock_irq(&dev->wl->irq_lock); ret = dfops->read(dev, buf, bufsize); spin_unlock_irq(&dev->wl->irq_lock); } else ret = dfops->read(dev, buf, bufsize); if (ret <= 0) { free_pages((unsigned long)buf, buforder); err = ret; goto out_unlock; } dfile->data_len = ret; dfile->buffer = buf; } ret = simple_read_from_buffer(userbuf, count, ppos, dfile->buffer, dfile->data_len); if (*ppos >= dfile->data_len) { free_pages((unsigned long)dfile->buffer, buforder); dfile->buffer = NULL; dfile->data_len = 0; } out_unlock: mutex_unlock(&dev->wl->mutex); return err ? err : ret; }