Skip to content

Commit

Permalink
net: apple: bmac: Fix build since dev_addr constification
Browse files Browse the repository at this point in the history
Since commit adeef3e ("net: constify netdev->dev_addr") the bmac
driver no longer builds with the following errors (pmac32_defconfig):

  linux/drivers/net/ethernet/apple/bmac.c: In function ‘bmac_probe’:
  linux/drivers/net/ethernet/apple/bmac.c:1287:20: error: assignment of read-only location ‘*(dev->dev_addr + (sizetype)j)’
   1287 |   dev->dev_addr[j] = rev ? bitrev8(addr[j]): addr[j];
        |                    ^

Fix it by making the modifications to a local macaddr variable and then
passing that to eth_hw_addr_set().

We don't use the existing addr variable because the bitrev8() would
mutate it, but it is already used unreversed later in the function.

Signed-off-by: Michael Ellerman <[email protected]>
Reviewed-by: Jakub Kicinski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
mpe authored and davem330 committed Jan 14, 2022
1 parent 6c8dc12 commit ea93824
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/ethernet/apple/bmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,7 @@ static int bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)
struct bmac_data *bp;
const unsigned char *prop_addr;
unsigned char addr[6];
u8 macaddr[6];
struct net_device *dev;
int is_bmac_plus = ((int)match->data) != 0;

Expand Down Expand Up @@ -1284,7 +1285,9 @@ static int bmac_probe(struct macio_dev *mdev, const struct of_device_id *match)

rev = addr[0] == 0 && addr[1] == 0xA0;
for (j = 0; j < 6; ++j)
dev->dev_addr[j] = rev ? bitrev8(addr[j]): addr[j];
macaddr[j] = rev ? bitrev8(addr[j]): addr[j];

eth_hw_addr_set(dev, macaddr);

/* Enable chip without interrupts for now */
bmac_enable_and_reset_chip(dev);
Expand Down

0 comments on commit ea93824

Please sign in to comment.