static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
*val = readb(regs + (page << 8) + reg);
static int b53_mmap_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
if (WARN_ON(reg % 2))
return -EINVAL;
static int b53_mmap_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
if (WARN_ON(reg % 4))
return -EINVAL;
static int b53_mmap_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
if (WARN_ON(reg % 2))
return -EINVAL;
static int b53_mmap_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
u32 hi, lo;
if (WARN_ON(reg % 4))
static int b53_mmap_write8(struct b53_device *dev, u8 page, u8 reg, u8 value)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
writeb(value, regs + (page << 8) + reg);
static int b53_mmap_write16(struct b53_device *dev, u8 page, u8 reg,
u16 value)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
if (WARN_ON(reg % 2))
return -EINVAL;
static int b53_mmap_write32(struct b53_device *dev, u8 page, u8 reg,
u32 value)
{
- u8 __iomem *regs = dev->priv;
+ struct b53_mmap_priv *priv = dev->priv;
+ void __iomem *regs = priv->regs;
if (WARN_ON(reg % 4))
return -EINVAL;
static int b53_mmap_probe(struct platform_device *pdev)
{
struct b53_platform_data *pdata = pdev->dev.platform_data;
+ struct b53_mmap_priv *priv;
struct b53_device *dev;
if (!pdata)
return -EINVAL;
- dev = b53_switch_alloc(&pdev->dev, &b53_mmap_ops, pdata->regs);
+ priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->regs = pdata->regs;
+
+ dev = b53_switch_alloc(&pdev->dev, &b53_mmap_ops, priv);
if (!dev)
return -ENOMEM;