Skip to content

Commit

Permalink
ptp_qoriq: don't pass a large struct by value but instead pass it by …
Browse files Browse the repository at this point in the history
…reference

Passing the struct ptp_clock_info caps by parameter is passing over 130 bytes
of data by value on the stack. Optimize this by passing it by reference instead.
Also shinks the object code size:

Before:
   text	   data	    bss	    dec	    hex	filename
  12596	   2160	     64	  14820	   39e4	drivers/ptp/ptp_qoriq.o

After:
   text	   data	    bss	    dec	    hex	filename
  12567	   2160	     64	  14791	   39c7	drivers/ptp/ptp_qoriq.o

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Colin Ian King authored and David S. Miller committed Feb 19, 2019
1 parent d2cf821 commit 58066ac
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/freescale/enetc/enetc_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int enetc_ptp_probe(struct pci_dev *pdev,

ptp_qoriq->dev = &pdev->dev;

err = ptp_qoriq_init(ptp_qoriq, base, enetc_ptp_caps);
err = ptp_qoriq_init(ptp_qoriq, base, &enetc_ptp_caps);
if (err)
goto err_no_clock;

Expand Down
6 changes: 3 additions & 3 deletions drivers/ptp/ptp_qoriq.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ static int ptp_qoriq_auto_config(struct ptp_qoriq *ptp_qoriq,
}

int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
const struct ptp_clock_info caps)
const struct ptp_clock_info *caps)
{
struct device_node *node = ptp_qoriq->dev->of_node;
struct ptp_qoriq_registers *regs;
Expand All @@ -468,7 +468,7 @@ int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
u32 tmr_ctrl;

ptp_qoriq->base = base;
ptp_qoriq->caps = caps;
ptp_qoriq->caps = *caps;

if (of_property_read_u32(node, "fsl,cksel", &ptp_qoriq->cksel))
ptp_qoriq->cksel = DEFAULT_CKSEL;
Expand Down Expand Up @@ -605,7 +605,7 @@ static int ptp_qoriq_probe(struct platform_device *dev)
goto no_ioremap;
}

err = ptp_qoriq_init(ptp_qoriq, base, ptp_qoriq_caps);
err = ptp_qoriq_init(ptp_qoriq, base, &ptp_qoriq_caps);
if (err)
goto no_clock;

Expand Down
2 changes: 1 addition & 1 deletion include/linux/fsl/ptp_qoriq.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static inline void qoriq_write_le(unsigned __iomem *addr, u32 val)

irqreturn_t ptp_qoriq_isr(int irq, void *priv);
int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
const struct ptp_clock_info caps);
const struct ptp_clock_info *caps);
void ptp_qoriq_free(struct ptp_qoriq *ptp_qoriq);
int ptp_qoriq_adjfine(struct ptp_clock_info *ptp, long scaled_ppm);
int ptp_qoriq_adjtime(struct ptp_clock_info *ptp, s64 delta);
Expand Down

0 comments on commit 58066ac

Please sign in to comment.