summaryrefslogtreecommitdiffstats
path: root/drivers/net/phy/spi_ks8995.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-08 12:41:23 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-08 12:41:23 -0700
commitce7613db2d8d4d5af2587ab5d7090055c4562201 (patch)
treebc1037a83581e27e9a3f9d52b8e073a0a803a964 /drivers/net/phy/spi_ks8995.c
parent0afccc4ccecf8436b8e59369b384f6d0a56c90d1 (diff)
parent52c35befb69b005c3fc5afdaae3a5717ad013411 (diff)
downloadop-kernel-dev-ce7613db2d8d4d5af2587ab5d7090055c4562201.zip
op-kernel-dev-ce7613db2d8d4d5af2587ab5d7090055c4562201.tar.gz
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull more networking updates from David Miller: 1) If a VXLAN interface is created with no groups, we can crash on reception of packets. Fix from Mike Rapoport. 2) Missing includes in CPTS driver, from Alexei Starovoitov. 3) Fix string validations in isdnloop driver, from YOSHIFUJI Hideaki and Dan Carpenter. 4) Missing irq.h include in bnxw2x, enic, and qlcnic drivers. From Josh Boyer. 5) AF_PACKET transmit doesn't statistically count TX drops, from Daniel Borkmann. 6) Byte-Queue-Limit enabled drivers aren't handled properly in AF_PACKET transmit path, also from Daniel Borkmann. Same problem exists in pktgen, and Daniel fixed it there too. 7) Fix resource leaks in driver probe error paths of new sxgbe driver, from Francois Romieu. 8) Truesize of SKBs can gradually get more and more corrupted in NAPI packet recycling path, fix from Eric Dumazet. 9) Fix uniprocessor netfilter build, from Florian Westphal. In the longer term we should perhaps try to find a way for ARRAY_SIZE() to work even with zero sized array elements. 10) Fix crash in netfilter conntrack extensions due to mis-estimation of required extension space. From Andrey Vagin. 11) Since we commit table rule updates before trying to copy the counters back to userspace (it's the last action we perform), we really can't signal the user copy with an error as we are beyond the point from which we can unwind everything. This causes all kinds of use after free crashes and other mysterious behavior. From Thomas Graf. 12) Restore previous behvaior of div/mod by zero in BPF filter processing. From Daniel Borkmann. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (38 commits) net: sctp: wake up all assocs if sndbuf policy is per socket isdnloop: several buffer overflows netdev: remove potentially harmful checks pktgen: fix xmit test for BQL enabled devices net/at91_ether: avoid NULL pointer dereference tipc: Let tipc_release() return 0 at86rf230: fix MAX_CSMA_RETRIES parameter mac802154: fix duplicate #include headers sxgbe: fix duplicate #include headers net: filter: be more defensive on div/mod by X==0 netfilter: Can't fail and free after table replacement xen-netback: Trivial format string fix net: bcmgenet: Remove unnecessary version.h inclusion net: smc911x: Remove unused local variable bonding: Inactive slaves should keep inactive flag's value netfilter: nf_tables: fix wrong format in request_module() netfilter: nf_tables: set names cannot be larger than 15 bytes netfilter: nf_conntrack: reserve two bytes for nf_ct_ext->len netfilter: Add {ipt,ip6t}_osf aliases for xt_osf netfilter: x_tables: allow to use cgroup match for LOCAL_IN nf hooks ...
Diffstat (limited to 'drivers/net/phy/spi_ks8995.c')
-rw-r--r--drivers/net/phy/spi_ks8995.c52
1 files changed, 40 insertions, 12 deletions
diff --git a/drivers/net/phy/spi_ks8995.c b/drivers/net/phy/spi_ks8995.c
index 4cf5fb9..22b047f 100644
--- a/drivers/net/phy/spi_ks8995.c
+++ b/drivers/net/phy/spi_ks8995.c
@@ -1,5 +1,5 @@
/*
- * SPI driver for Micrel/Kendin KS8995M ethernet switch
+ * SPI driver for Micrel/Kendin KS8995M and KSZ8864RMN ethernet switches
*
* Copyright (C) 2008 Gabor Juhos <juhosg at openwrt.org>
*
@@ -70,7 +70,10 @@
#define KS8995_REG_IAD1 0x76 /* Indirect Access Data 1 */
#define KS8995_REG_IAD0 0x77 /* Indirect Access Data 0 */
+#define KSZ8864_REG_ID1 0xfe /* Chip ID in bit 7 */
+
#define KS8995_REGS_SIZE 0x80
+#define KSZ8864_REGS_SIZE 0x100
#define ID1_CHIPID_M 0xf
#define ID1_CHIPID_S 4
@@ -94,6 +97,7 @@ struct ks8995_switch {
struct spi_device *spi;
struct mutex lock;
struct ks8995_pdata *pdata;
+ struct bin_attribute regs_attr;
};
static inline u8 get_chip_id(u8 val)
@@ -216,11 +220,11 @@ static ssize_t ks8995_registers_read(struct file *filp, struct kobject *kobj,
dev = container_of(kobj, struct device, kobj);
ks8995 = dev_get_drvdata(dev);
- if (unlikely(off > KS8995_REGS_SIZE))
+ if (unlikely(off > ks8995->regs_attr.size))
return 0;
- if ((off + count) > KS8995_REGS_SIZE)
- count = KS8995_REGS_SIZE - off;
+ if ((off + count) > ks8995->regs_attr.size)
+ count = ks8995->regs_attr.size - off;
if (unlikely(!count))
return count;
@@ -238,11 +242,11 @@ static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
dev = container_of(kobj, struct device, kobj);
ks8995 = dev_get_drvdata(dev);
- if (unlikely(off >= KS8995_REGS_SIZE))
+ if (unlikely(off >= ks8995->regs_attr.size))
return -EFBIG;
- if ((off + count) > KS8995_REGS_SIZE)
- count = KS8995_REGS_SIZE - off;
+ if ((off + count) > ks8995->regs_attr.size)
+ count = ks8995->regs_attr.size - off;
if (unlikely(!count))
return count;
@@ -251,7 +255,7 @@ static ssize_t ks8995_registers_write(struct file *filp, struct kobject *kobj,
}
-static struct bin_attribute ks8995_registers_attr = {
+static const struct bin_attribute ks8995_registers_attr = {
.attr = {
.name = "registers",
.mode = S_IRUSR | S_IWUSR,
@@ -306,20 +310,44 @@ static int ks8995_probe(struct spi_device *spi)
goto err_drvdata;
}
+ memcpy(&ks->regs_attr, &ks8995_registers_attr, sizeof(ks->regs_attr));
+ if (get_chip_id(ids[1]) != CHIPID_M) {
+ u8 val;
+
+ /* Check if this is a KSZ8864RMN */
+ err = ks8995_read(ks, &val, KSZ8864_REG_ID1, sizeof(val));
+ if (err < 0) {
+ dev_err(&spi->dev,
+ "unable to read chip id register, err=%d\n",
+ err);
+ goto err_drvdata;
+ }
+ if ((val & 0x80) == 0) {
+ dev_err(&spi->dev, "unknown chip:%02x,0\n", ids[1]);
+ goto err_drvdata;
+ }
+ ks->regs_attr.size = KSZ8864_REGS_SIZE;
+ }
+
err = ks8995_reset(ks);
if (err)
goto err_drvdata;
- err = sysfs_create_bin_file(&spi->dev.kobj, &ks8995_registers_attr);
+ err = sysfs_create_bin_file(&spi->dev.kobj, &ks->regs_attr);
if (err) {
dev_err(&spi->dev, "unable to create sysfs file, err=%d\n",
err);
goto err_drvdata;
}
- dev_info(&spi->dev, "KS89%02X device found, Chip ID:%01x, "
- "Revision:%01x\n", ids[0],
- get_chip_id(ids[1]), get_chip_rev(ids[1]));
+ if (get_chip_id(ids[1]) == CHIPID_M) {
+ dev_info(&spi->dev,
+ "KS8995 device found, Chip ID:%x, Revision:%x\n",
+ get_chip_id(ids[1]), get_chip_rev(ids[1]));
+ } else {
+ dev_info(&spi->dev, "KSZ8864 device found, Revision:%x\n",
+ get_chip_rev(ids[1]));
+ }
return 0;
OpenPOWER on IntegriCloud