~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to drivers/net/phy/phy.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <linux/string.h>
20
20
#include <linux/errno.h>
21
21
#include <linux/unistd.h>
22
 
#include <linux/slab.h>
23
22
#include <linux/interrupt.h>
24
23
#include <linux/init.h>
25
24
#include <linux/delay.h>
48
47
        pr_info("PHY: %s - Link is %s", dev_name(&phydev->dev),
49
48
                        phydev->link ? "Up" : "Down");
50
49
        if (phydev->link)
51
 
                printk(" - %d/%s", phydev->speed,
 
50
                printk(KERN_CONT " - %d/%s", phydev->speed,
52
51
                                DUPLEX_FULL == phydev->duplex ?
53
52
                                "Full" : "Half");
54
53
 
55
 
        printk("\n");
 
54
        printk(KERN_CONT "\n");
56
55
}
57
56
EXPORT_SYMBOL(phy_print_status);
58
57
 
66
65
 *
67
66
 * Returns 0 on success on < 0 on error.
68
67
 */
69
 
int phy_clear_interrupt(struct phy_device *phydev)
 
68
static int phy_clear_interrupt(struct phy_device *phydev)
70
69
{
71
70
        int err = 0;
72
71
 
83
82
 *
84
83
 * Returns 0 on success on < 0 on error.
85
84
 */
86
 
int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
 
85
static int phy_config_interrupt(struct phy_device *phydev, u32 interrupts)
87
86
{
88
87
        int err = 0;
89
88
 
209
208
 *   duplexes.  Drop down by one in this order:  1000/FULL,
210
209
 *   1000/HALF, 100/FULL, 100/HALF, 10/FULL, 10/HALF.
211
210
 */
212
 
void phy_sanitize_settings(struct phy_device *phydev)
 
211
static void phy_sanitize_settings(struct phy_device *phydev)
213
212
{
214
213
        u32 features = phydev->supported;
215
214
        int idx;
224
223
        phydev->speed = settings[idx].speed;
225
224
        phydev->duplex = settings[idx].duplex;
226
225
}
227
 
EXPORT_SYMBOL(phy_sanitize_settings);
228
226
 
229
227
/**
230
228
 * phy_ethtool_sset - generic ethtool sset function, handles all the details
254
252
        if (cmd->autoneg == AUTONEG_ENABLE && cmd->advertising == 0)
255
253
                return -EINVAL;
256
254
 
257
 
        if (cmd->autoneg == AUTONEG_DISABLE
258
 
                        && ((cmd->speed != SPEED_1000
259
 
                                        && cmd->speed != SPEED_100
260
 
                                        && cmd->speed != SPEED_10)
261
 
                                || (cmd->duplex != DUPLEX_HALF
262
 
                                        && cmd->duplex != DUPLEX_FULL)))
 
255
        if (cmd->autoneg == AUTONEG_DISABLE &&
 
256
            ((cmd->speed != SPEED_1000 &&
 
257
              cmd->speed != SPEED_100 &&
 
258
              cmd->speed != SPEED_10) ||
 
259
             (cmd->duplex != DUPLEX_HALF &&
 
260
              cmd->duplex != DUPLEX_FULL)))
263
261
                return -EINVAL;
264
262
 
265
263
        phydev->autoneg = cmd->autoneg;
302
300
/**
303
301
 * phy_mii_ioctl - generic PHY MII ioctl interface
304
302
 * @phydev: the phy_device struct
305
 
 * @mii_data: MII ioctl data
 
303
 * @ifr: &struct ifreq for socket ioctl's
306
304
 * @cmd: ioctl cmd to execute
307
305
 *
308
306
 * Note that this function is currently incompatible with the
310
308
 * current state.  Use at own risk.
311
309
 */
312
310
int phy_mii_ioctl(struct phy_device *phydev,
313
 
                struct mii_ioctl_data *mii_data, int cmd)
 
311
                struct ifreq *ifr, int cmd)
314
312
{
 
313
        struct mii_ioctl_data *mii_data = if_mii(ifr);
315
314
        u16 val = mii_data->val_in;
316
315
 
317
316
        switch (cmd) {
353
352
 
354
353
                phy_write(phydev, mii_data->reg_num, val);
355
354
                
356
 
                if (mii_data->reg_num == MII_BMCR 
357
 
                                && val & BMCR_RESET
358
 
                                && phydev->drv->config_init) {
 
355
                if (mii_data->reg_num == MII_BMCR &&
 
356
                    val & BMCR_RESET &&
 
357
                    phydev->drv->config_init) {
359
358
                        phy_scan_fixups(phydev);
360
359
                        phydev->drv->config_init(phydev);
361
360
                }
362
361
                break;
363
362
 
 
363
        case SIOCSHWTSTAMP:
 
364
                if (phydev->drv->hwtstamp)
 
365
                        return phydev->drv->hwtstamp(phydev, ifr);
 
366
                /* fall through */
 
367
 
364
368
        default:
365
369
                return -EOPNOTSUPP;
366
370
        }
410
414
 
411
415
 
412
416
static void phy_change(struct work_struct *work);
413
 
static void phy_state_machine(struct work_struct *work);
414
417
 
415
418
/**
416
419
 * phy_start_machine - start PHY state machine tracking
430
433
{
431
434
        phydev->adjust_state = handler;
432
435
 
433
 
        INIT_DELAYED_WORK(&phydev->state_queue, phy_state_machine);
434
436
        schedule_delayed_work(&phydev->state_queue, HZ);
435
437
}
436
438
 
529
531
 * phy_enable_interrupts - Enable the interrupts from the PHY side
530
532
 * @phydev: target phy_device struct
531
533
 */
532
 
int phy_enable_interrupts(struct phy_device *phydev)
 
534
static int phy_enable_interrupts(struct phy_device *phydev)
533
535
{
534
536
        int err;
535
537
 
542
544
 
543
545
        return err;
544
546
}
545
 
EXPORT_SYMBOL(phy_enable_interrupts);
546
547
 
547
548
/**
548
549
 * phy_disable_interrupts - Disable the PHY interrupts from the PHY side
549
550
 * @phydev: target phy_device struct
550
551
 */
551
 
int phy_disable_interrupts(struct phy_device *phydev)
 
552
static int phy_disable_interrupts(struct phy_device *phydev)
552
553
{
553
554
        int err;
554
555
 
571
572
 
572
573
        return err;
573
574
}
574
 
EXPORT_SYMBOL(phy_disable_interrupts);
575
575
 
576
576
/**
577
577
 * phy_start_interrupts - request and enable interrupts for a PHY device
761
761
 * phy_state_machine - Handle the state machine
762
762
 * @work: work_struct that describes the work to be done
763
763
 */
764
 
static void phy_state_machine(struct work_struct *work)
 
764
void phy_state_machine(struct work_struct *work)
765
765
{
766
766
        struct delayed_work *dwork = to_delayed_work(work);
767
767
        struct phy_device *phydev =