diff mbox

[2/5] kbuild: treat a directory listed in a composite object as foo/mod.a

Message ID 152929772044.17463.14049121557186779554.stgit@noble (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown June 18, 2018, 4:55 a.m. UTC
Currently a directory is not permitted in a composite
object.
This patch changes kbuild so that a directory it assumed
to mean the file "mod.a" in that directory.
The file cannot, yet, be created, so this does not yet
affect behaviour.

There are several parts to this.

1/ strip out all the directories from obj-m so that
  the directories that appear in real-obj-m must be
  parts of composite objects
2/ translate those directories from foo/ to foo/mod.a
  at the same time that obj-y directories becomes foo/built-in.a
3/ hold list of directories needed for modules in subdir-obj-m
  so that we can descend into them as required.
4/ We need a little "dance" in "Rule to link composite objects"
  where we strip the mod.a back off - so we can filter against
  the foo-{objs,y,m} macros, then add it back on for
  declaring dependencies.
  As part of this, multi_depend gains an extra argument
  being the name to append to any directory.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 scripts/Makefile.build |   15 ++++++++-------
 scripts/Makefile.lib   |   19 +++++++++++++++----
 2 files changed, 23 insertions(+), 11 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

kernel test robot June 18, 2018, 9:14 a.m. UTC | #1
Hi NeilBrown,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kbuild/for-next]
[also build test ERROR on v4.18-rc1 next-20180618]
[cannot apply to mmarek/for-next mmarek/rc-fixes]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/NeilBrown/kbuild-build-modules-from-code-in-multiple-directories/20180618-130250
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
config: x86_64-randconfig-in0-06170623 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `release_hw':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1757: undefined reference to `l1_event'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1759: undefined reference to `mISDN_unregister_device'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1760: undefined reference to `mISDN_freebchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1761: undefined reference to `mISDN_freebchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1762: undefined reference to `mISDN_freedchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `deactivate_bchannel':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1788: undefined reference to `mISDN_clear_bchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `ph_state_te':
   drivers/isdn/hardware/mISDN/hfcsusb.c:611: undefined reference to `l1_event'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `channel_bctrl':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:808: undefined reference to `mISDN_ctrl_bchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `tx_iso_complete':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1345: undefined reference to `get_next_dframe'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1348: undefined reference to `get_next_bframe'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcsusb_rx_frame':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:850: undefined reference to `bchannel_get_rxbuf'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:919: undefined reference to `recv_Dchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:921: undefined reference to `recv_Bchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:924: undefined reference to `recv_Echannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:943: undefined reference to `recv_Bchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1D':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:301: undefined reference to `dchannel_senddata'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:305: undefined reference to `queue_ch_frame'
   drivers/isdn/hardware/mISDN/hfcsusb.c:360: undefined reference to `l1_event'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `setup_instance':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1843: undefined reference to `mISDN_initdchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1852: undefined reference to `mISDN_initdchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1861: undefined reference to `mISDN_initbchannel'
>> drivers/isdn/hardware/mISDN/hfcsusb.c:1887: undefined reference to `mISDN_register_device'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1898: undefined reference to `mISDN_freebchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1899: undefined reference to `mISDN_freebchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.c:1900: undefined reference to `mISDN_freedchannel'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1B':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:224: undefined reference to `bchannel_senddata'
   drivers/isdn/hardware/mISDN/hfcsusb.o: In function `open_dchannel':
>> drivers/isdn/hardware/mISDN/hfcsusb.c:454: undefined reference to `create_l1'

vim +1757 drivers/isdn/hardware/mISDN/hfcsusb.c

69f52adb Karsten Keil  2009-01-09  1739  
69f52adb Karsten Keil  2009-01-09  1740  static void
69f52adb Karsten Keil  2009-01-09  1741  release_hw(struct hfcsusb *hw)
69f52adb Karsten Keil  2009-01-09  1742  {
69f52adb Karsten Keil  2009-01-09  1743  	if (debug & DBG_HFC_CALL_TRACE)
69f52adb Karsten Keil  2009-01-09  1744  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
69f52adb Karsten Keil  2009-01-09  1745  
69f52adb Karsten Keil  2009-01-09  1746  	/*
69f52adb Karsten Keil  2009-01-09  1747  	 * stop all endpoints gracefully
69f52adb Karsten Keil  2009-01-09  1748  	 * TODO: mISDN_core should generate CLOSE_CHANNEL
69f52adb Karsten Keil  2009-01-09  1749  	 *       signals after calling mISDN_unregister_device()
69f52adb Karsten Keil  2009-01-09  1750  	 */
69f52adb Karsten Keil  2009-01-09  1751  	hfcsusb_stop_endpoint(hw, HFC_CHAN_D);
69f52adb Karsten Keil  2009-01-09  1752  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B1);
69f52adb Karsten Keil  2009-01-09  1753  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B2);
69f52adb Karsten Keil  2009-01-09  1754  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
69f52adb Karsten Keil  2009-01-09  1755  		hfcsusb_stop_endpoint(hw, HFC_CHAN_E);
69f52adb Karsten Keil  2009-01-09  1756  	if (hw->protocol == ISDN_P_TE_S0)
69f52adb Karsten Keil  2009-01-09 @1757  		l1_event(hw->dch.l1, CLOSE_CHANNEL);
69f52adb Karsten Keil  2009-01-09  1758  
69f52adb Karsten Keil  2009-01-09 @1759  	mISDN_unregister_device(&hw->dch.dev);
69f52adb Karsten Keil  2009-01-09 @1760  	mISDN_freebchannel(&hw->bch[1]);
69f52adb Karsten Keil  2009-01-09 @1761  	mISDN_freebchannel(&hw->bch[0]);
69f52adb Karsten Keil  2009-01-09 @1762  	mISDN_freedchannel(&hw->dch);
69f52adb Karsten Keil  2009-01-09  1763  
69f52adb Karsten Keil  2009-01-09  1764  	if (hw->ctrl_urb) {
69f52adb Karsten Keil  2009-01-09  1765  		usb_kill_urb(hw->ctrl_urb);
69f52adb Karsten Keil  2009-01-09  1766  		usb_free_urb(hw->ctrl_urb);
69f52adb Karsten Keil  2009-01-09  1767  		hw->ctrl_urb = NULL;
69f52adb Karsten Keil  2009-01-09  1768  	}
69f52adb Karsten Keil  2009-01-09  1769  
69f52adb Karsten Keil  2009-01-09  1770  	if (hw->intf)
69f52adb Karsten Keil  2009-01-09  1771  		usb_set_intfdata(hw->intf, NULL);
69f52adb Karsten Keil  2009-01-09  1772  	list_del(&hw->list);
69f52adb Karsten Keil  2009-01-09  1773  	kfree(hw);
69f52adb Karsten Keil  2009-01-09  1774  	hw = NULL;
69f52adb Karsten Keil  2009-01-09  1775  }
69f52adb Karsten Keil  2009-01-09  1776  
69f52adb Karsten Keil  2009-01-09  1777  static void
69f52adb Karsten Keil  2009-01-09  1778  deactivate_bchannel(struct bchannel *bch)
69f52adb Karsten Keil  2009-01-09  1779  {
69f52adb Karsten Keil  2009-01-09  1780  	struct hfcsusb *hw = bch->hw;
69f52adb Karsten Keil  2009-01-09  1781  	u_long flags;
69f52adb Karsten Keil  2009-01-09  1782  
69f52adb Karsten Keil  2009-01-09  1783  	if (bch->debug & DEBUG_HW)
69f52adb Karsten Keil  2009-01-09  1784  		printk(KERN_DEBUG "%s: %s: bch->nr(%i)\n",
69f52adb Karsten Keil  2009-01-09  1785  		       hw->name, __func__, bch->nr);
69f52adb Karsten Keil  2009-01-09  1786  
69f52adb Karsten Keil  2009-01-09  1787  	spin_lock_irqsave(&hw->lock, flags);
fb286f04 Karsten Keil  2009-07-09 @1788  	mISDN_clear_bchannel(bch);
69f52adb Karsten Keil  2009-01-09  1789  	spin_unlock_irqrestore(&hw->lock, flags);
69f52adb Karsten Keil  2009-01-09  1790  	hfcsusb_setup_bch(bch, ISDN_P_NONE);
37952cfa Martin Bachem 2012-05-15  1791  	hfcsusb_stop_endpoint(hw, bch->nr - 1);
69f52adb Karsten Keil  2009-01-09  1792  }
69f52adb Karsten Keil  2009-01-09  1793  
69f52adb Karsten Keil  2009-01-09  1794  /*
69f52adb Karsten Keil  2009-01-09  1795   * Layer 1 B-channel hardware access
69f52adb Karsten Keil  2009-01-09  1796   */
69f52adb Karsten Keil  2009-01-09  1797  static int
69f52adb Karsten Keil  2009-01-09  1798  hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
69f52adb Karsten Keil  2009-01-09  1799  {
69f52adb Karsten Keil  2009-01-09  1800  	struct bchannel	*bch = container_of(ch, struct bchannel, ch);
69f52adb Karsten Keil  2009-01-09  1801  	int		ret = -EINVAL;
69f52adb Karsten Keil  2009-01-09  1802  
69f52adb Karsten Keil  2009-01-09  1803  	if (bch->debug & DEBUG_HW)
69f52adb Karsten Keil  2009-01-09  1804  		printk(KERN_DEBUG "%s: cmd:%x %p\n", __func__, cmd, arg);
69f52adb Karsten Keil  2009-01-09  1805  
69f52adb Karsten Keil  2009-01-09  1806  	switch (cmd) {
69f52adb Karsten Keil  2009-01-09  1807  	case HW_TESTRX_RAW:
69f52adb Karsten Keil  2009-01-09  1808  	case HW_TESTRX_HDLC:
69f52adb Karsten Keil  2009-01-09  1809  	case HW_TESTRX_OFF:
69f52adb Karsten Keil  2009-01-09  1810  		ret = -EINVAL;
69f52adb Karsten Keil  2009-01-09  1811  		break;
69f52adb Karsten Keil  2009-01-09  1812  
69f52adb Karsten Keil  2009-01-09  1813  	case CLOSE_CHANNEL:
69f52adb Karsten Keil  2009-01-09  1814  		test_and_clear_bit(FLG_OPEN, &bch->Flags);
69f52adb Karsten Keil  2009-01-09  1815  		deactivate_bchannel(bch);
69f52adb Karsten Keil  2009-01-09  1816  		ch->protocol = ISDN_P_NONE;
69f52adb Karsten Keil  2009-01-09  1817  		ch->peer = NULL;
69f52adb Karsten Keil  2009-01-09  1818  		module_put(THIS_MODULE);
69f52adb Karsten Keil  2009-01-09  1819  		ret = 0;
69f52adb Karsten Keil  2009-01-09  1820  		break;
69f52adb Karsten Keil  2009-01-09  1821  	case CONTROL_CHANNEL:
69f52adb Karsten Keil  2009-01-09  1822  		ret = channel_bctrl(bch, arg);
69f52adb Karsten Keil  2009-01-09  1823  		break;
69f52adb Karsten Keil  2009-01-09  1824  	default:
69f52adb Karsten Keil  2009-01-09  1825  		printk(KERN_WARNING "%s: unknown prim(%x)\n",
69f52adb Karsten Keil  2009-01-09  1826  		       __func__, cmd);
69f52adb Karsten Keil  2009-01-09  1827  	}
69f52adb Karsten Keil  2009-01-09  1828  	return ret;
69f52adb Karsten Keil  2009-01-09  1829  }
69f52adb Karsten Keil  2009-01-09  1830  
69f52adb Karsten Keil  2009-01-09  1831  static int
69f52adb Karsten Keil  2009-01-09  1832  setup_instance(struct hfcsusb *hw, struct device *parent)
69f52adb Karsten Keil  2009-01-09  1833  {
69f52adb Karsten Keil  2009-01-09  1834  	u_long	flags;
69f52adb Karsten Keil  2009-01-09  1835  	int	err, i;
69f52adb Karsten Keil  2009-01-09  1836  
69f52adb Karsten Keil  2009-01-09  1837  	if (debug & DBG_HFC_CALL_TRACE)
69f52adb Karsten Keil  2009-01-09  1838  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
69f52adb Karsten Keil  2009-01-09  1839  
69f52adb Karsten Keil  2009-01-09  1840  	spin_lock_init(&hw->ctrl_lock);
69f52adb Karsten Keil  2009-01-09  1841  	spin_lock_init(&hw->lock);
69f52adb Karsten Keil  2009-01-09  1842  
69f52adb Karsten Keil  2009-01-09 @1843  	mISDN_initdchannel(&hw->dch, MAX_DFRAME_LEN_L1, ph_state);
69f52adb Karsten Keil  2009-01-09  1844  	hw->dch.debug = debug & 0xFFFF;
69f52adb Karsten Keil  2009-01-09  1845  	hw->dch.hw = hw;
69f52adb Karsten Keil  2009-01-09  1846  	hw->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
69f52adb Karsten Keil  2009-01-09  1847  	hw->dch.dev.D.send = hfcusb_l2l1D;
69f52adb Karsten Keil  2009-01-09  1848  	hw->dch.dev.D.ctrl = hfc_dctrl;
69f52adb Karsten Keil  2009-01-09  1849  
69f52adb Karsten Keil  2009-01-09  1850  	/* enable E-Channel logging */
69f52adb Karsten Keil  2009-01-09  1851  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
69f52adb Karsten Keil  2009-01-09 @1852  		mISDN_initdchannel(&hw->ech, MAX_DFRAME_LEN_L1, NULL);
69f52adb Karsten Keil  2009-01-09  1853  
69f52adb Karsten Keil  2009-01-09  1854  	hw->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
69f52adb Karsten Keil  2009-01-09  1855  		(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
69f52adb Karsten Keil  2009-01-09  1856  	hw->dch.dev.nrbchan = 2;
69f52adb Karsten Keil  2009-01-09  1857  	for (i = 0; i < 2; i++) {
69f52adb Karsten Keil  2009-01-09  1858  		hw->bch[i].nr = i + 1;
69f52adb Karsten Keil  2009-01-09  1859  		set_channelmap(i + 1, hw->dch.dev.channelmap);
69f52adb Karsten Keil  2009-01-09  1860  		hw->bch[i].debug = debug;
034005a0 Karsten Keil  2012-05-15 @1861  		mISDN_initbchannel(&hw->bch[i], MAX_DATA_MEM, poll >> 1);
69f52adb Karsten Keil  2009-01-09  1862  		hw->bch[i].hw = hw;
69f52adb Karsten Keil  2009-01-09  1863  		hw->bch[i].ch.send = hfcusb_l2l1B;
69f52adb Karsten Keil  2009-01-09  1864  		hw->bch[i].ch.ctrl = hfc_bctrl;
69f52adb Karsten Keil  2009-01-09  1865  		hw->bch[i].ch.nr = i + 1;
69f52adb Karsten Keil  2009-01-09  1866  		list_add(&hw->bch[i].ch.list, &hw->dch.dev.bchannels);
69f52adb Karsten Keil  2009-01-09  1867  	}
69f52adb Karsten Keil  2009-01-09  1868  
69f52adb Karsten Keil  2009-01-09  1869  	hw->fifos[HFCUSB_B1_TX].bch = &hw->bch[0];
69f52adb Karsten Keil  2009-01-09  1870  	hw->fifos[HFCUSB_B1_RX].bch = &hw->bch[0];
69f52adb Karsten Keil  2009-01-09  1871  	hw->fifos[HFCUSB_B2_TX].bch = &hw->bch[1];
69f52adb Karsten Keil  2009-01-09  1872  	hw->fifos[HFCUSB_B2_RX].bch = &hw->bch[1];
69f52adb Karsten Keil  2009-01-09  1873  	hw->fifos[HFCUSB_D_TX].dch = &hw->dch;
69f52adb Karsten Keil  2009-01-09  1874  	hw->fifos[HFCUSB_D_RX].dch = &hw->dch;
69f52adb Karsten Keil  2009-01-09  1875  	hw->fifos[HFCUSB_PCM_RX].ech = &hw->ech;
69f52adb Karsten Keil  2009-01-09  1876  	hw->fifos[HFCUSB_PCM_TX].ech = &hw->ech;
69f52adb Karsten Keil  2009-01-09  1877  
69f52adb Karsten Keil  2009-01-09  1878  	err = setup_hfcsusb(hw);
69f52adb Karsten Keil  2009-01-09  1879  	if (err)
69f52adb Karsten Keil  2009-01-09  1880  		goto out;
69f52adb Karsten Keil  2009-01-09  1881  
69f52adb Karsten Keil  2009-01-09  1882  	snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s.%d", DRIVER_NAME,
69f52adb Karsten Keil  2009-01-09  1883  		 hfcsusb_cnt + 1);
69f52adb Karsten Keil  2009-01-09  1884  	printk(KERN_INFO "%s: registered as '%s'\n",
69f52adb Karsten Keil  2009-01-09  1885  	       DRIVER_NAME, hw->name);
69f52adb Karsten Keil  2009-01-09  1886  
69f52adb Karsten Keil  2009-01-09 @1887  	err = mISDN_register_device(&hw->dch.dev, parent, hw->name);
69f52adb Karsten Keil  2009-01-09  1888  	if (err)
69f52adb Karsten Keil  2009-01-09  1889  		goto out;
69f52adb Karsten Keil  2009-01-09  1890  
69f52adb Karsten Keil  2009-01-09  1891  	hfcsusb_cnt++;
69f52adb Karsten Keil  2009-01-09  1892  	write_lock_irqsave(&HFClock, flags);
69f52adb Karsten Keil  2009-01-09  1893  	list_add_tail(&hw->list, &HFClist);
69f52adb Karsten Keil  2009-01-09  1894  	write_unlock_irqrestore(&HFClock, flags);
69f52adb Karsten Keil  2009-01-09  1895  	return 0;
69f52adb Karsten Keil  2009-01-09  1896  
69f52adb Karsten Keil  2009-01-09  1897  out:
69f52adb Karsten Keil  2009-01-09  1898  	mISDN_freebchannel(&hw->bch[1]);
69f52adb Karsten Keil  2009-01-09  1899  	mISDN_freebchannel(&hw->bch[0]);
69f52adb Karsten Keil  2009-01-09  1900  	mISDN_freedchannel(&hw->dch);
69f52adb Karsten Keil  2009-01-09  1901  	kfree(hw);
69f52adb Karsten Keil  2009-01-09  1902  	return err;
69f52adb Karsten Keil  2009-01-09  1903  }
69f52adb Karsten Keil  2009-01-09  1904  

:::::: The code at line 1757 was first introduced by commit
:::::: 69f52adb2d534afc41fcc658f155e01f0b322f9e mISDN: Add HFC USB driver

:::::: TO: Karsten Keil <kkeil@suse.de>
:::::: CC: Karsten Keil <kkeil@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
NeilBrown June 18, 2018, 10:30 p.m. UTC | #2
On Mon, Jun 18 2018, kbuild test robot wrote:

> Hi NeilBrown,
>
> Thank you for the patch! Yet something to improve:


Thank you for your testing and problem report! Yet something to improve:-)

This bug is caused by the combination CONFIG_MISDN_HFCUSB=y and CONFIG_MISDN=m
and appears to have nothing to do with my patch.
I suspect drivers/isdn/hardware/mISDN/Kconfig needs

@@ -35,6 +35,7 @@ config MISDN_HFCMULTI_8xx
 config MISDN_HFCUSB
 	tristate "Support for HFC-S USB based TAs"
 	depends on USB
+	depends on MISDN
 	help
 	  Enable support for USB ISDN TAs with Cologne Chip AG's
 	  HFC-S USB ISDN Controller

or similar.

Thanks,
NeilBrown

(config file excerpt for Karsten:
CONFIG_MISDN=m
CONFIG_MISDN_DSP=m
CONFIG_MISDN_L1OIP=m
CONFIG_MISDN_HFCPCI=m
# CONFIG_MISDN_HFCMULTI is not set
CONFIG_MISDN_HFCUSB=y
CONFIG_MISDN_AVMFRITZ=m
CONFIG_MISDN_SPEEDFAX=m
CONFIG_MISDN_INFINEON=m
CONFIG_MISDN_W6692=m
# CONFIG_MISDN_NETJET is not set
CONFIG_MISDN_IPAC=m
CONFIG_MISDN_ISAR=m
)

>
> [auto build test ERROR on kbuild/for-next]
> [also build test ERROR on v4.18-rc1 next-20180618]
> [cannot apply to mmarek/for-next mmarek/rc-fixes]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url:    https://github.com/0day-ci/linux/commits/NeilBrown/kbuild-build-modules-from-code-in-multiple-directories/20180618-130250
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
> config: x86_64-randconfig-in0-06170623 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=x86_64 
>
> All errors (new ones prefixed by >>):
>
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `release_hw':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1757: undefined reference to `l1_event'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1759: undefined reference to `mISDN_unregister_device'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1760: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1761: undefined reference to `mISDN_freebchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1762: undefined reference to `mISDN_freedchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `deactivate_bchannel':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1788: undefined reference to `mISDN_clear_bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `ph_state_te':
>    drivers/isdn/hardware/mISDN/hfcsusb.c:611: undefined reference to `l1_event'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `channel_bctrl':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:808: undefined reference to `mISDN_ctrl_bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `tx_iso_complete':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1345: undefined reference to `get_next_dframe'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1348: undefined reference to `get_next_bframe'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcsusb_rx_frame':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:850: undefined reference to `bchannel_get_rxbuf'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:919: undefined reference to `recv_Dchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:921: undefined reference to `recv_Bchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:924: undefined reference to `recv_Echannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:943: undefined reference to `recv_Bchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1D':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:301: undefined reference to `dchannel_senddata'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:305: undefined reference to `queue_ch_frame'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:360: undefined reference to `l1_event'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `setup_instance':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1843: undefined reference to `mISDN_initdchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1852: undefined reference to `mISDN_initdchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1861: undefined reference to `mISDN_initbchannel'
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:1887: undefined reference to `mISDN_register_device'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1898: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1899: undefined reference to `mISDN_freebchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.c:1900: undefined reference to `mISDN_freedchannel'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `hfcusb_l2l1B':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:224: undefined reference to `bchannel_senddata'
>    drivers/isdn/hardware/mISDN/hfcsusb.o: In function `open_dchannel':
>>> drivers/isdn/hardware/mISDN/hfcsusb.c:454: undefined reference to `create_l1'
>
> vim +1757 drivers/isdn/hardware/mISDN/hfcsusb.c
>
> 69f52adb Karsten Keil  2009-01-09  1739  
> 69f52adb Karsten Keil  2009-01-09  1740  static void
> 69f52adb Karsten Keil  2009-01-09  1741  release_hw(struct hfcsusb *hw)
> 69f52adb Karsten Keil  2009-01-09  1742  {
> 69f52adb Karsten Keil  2009-01-09  1743  	if (debug & DBG_HFC_CALL_TRACE)
> 69f52adb Karsten Keil  2009-01-09  1744  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
> 69f52adb Karsten Keil  2009-01-09  1745  
> 69f52adb Karsten Keil  2009-01-09  1746  	/*
> 69f52adb Karsten Keil  2009-01-09  1747  	 * stop all endpoints gracefully
> 69f52adb Karsten Keil  2009-01-09  1748  	 * TODO: mISDN_core should generate CLOSE_CHANNEL
> 69f52adb Karsten Keil  2009-01-09  1749  	 *       signals after calling mISDN_unregister_device()
> 69f52adb Karsten Keil  2009-01-09  1750  	 */
> 69f52adb Karsten Keil  2009-01-09  1751  	hfcsusb_stop_endpoint(hw, HFC_CHAN_D);
> 69f52adb Karsten Keil  2009-01-09  1752  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B1);
> 69f52adb Karsten Keil  2009-01-09  1753  	hfcsusb_stop_endpoint(hw, HFC_CHAN_B2);
> 69f52adb Karsten Keil  2009-01-09  1754  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
> 69f52adb Karsten Keil  2009-01-09  1755  		hfcsusb_stop_endpoint(hw, HFC_CHAN_E);
> 69f52adb Karsten Keil  2009-01-09  1756  	if (hw->protocol == ISDN_P_TE_S0)
> 69f52adb Karsten Keil  2009-01-09 @1757  		l1_event(hw->dch.l1, CLOSE_CHANNEL);
> 69f52adb Karsten Keil  2009-01-09  1758  
> 69f52adb Karsten Keil  2009-01-09 @1759  	mISDN_unregister_device(&hw->dch.dev);
> 69f52adb Karsten Keil  2009-01-09 @1760  	mISDN_freebchannel(&hw->bch[1]);
> 69f52adb Karsten Keil  2009-01-09 @1761  	mISDN_freebchannel(&hw->bch[0]);
> 69f52adb Karsten Keil  2009-01-09 @1762  	mISDN_freedchannel(&hw->dch);
> 69f52adb Karsten Keil  2009-01-09  1763  
> 69f52adb Karsten Keil  2009-01-09  1764  	if (hw->ctrl_urb) {
> 69f52adb Karsten Keil  2009-01-09  1765  		usb_kill_urb(hw->ctrl_urb);
> 69f52adb Karsten Keil  2009-01-09  1766  		usb_free_urb(hw->ctrl_urb);
> 69f52adb Karsten Keil  2009-01-09  1767  		hw->ctrl_urb = NULL;
> 69f52adb Karsten Keil  2009-01-09  1768  	}
> 69f52adb Karsten Keil  2009-01-09  1769  
> 69f52adb Karsten Keil  2009-01-09  1770  	if (hw->intf)
> 69f52adb Karsten Keil  2009-01-09  1771  		usb_set_intfdata(hw->intf, NULL);
> 69f52adb Karsten Keil  2009-01-09  1772  	list_del(&hw->list);
> 69f52adb Karsten Keil  2009-01-09  1773  	kfree(hw);
> 69f52adb Karsten Keil  2009-01-09  1774  	hw = NULL;
> 69f52adb Karsten Keil  2009-01-09  1775  }
> 69f52adb Karsten Keil  2009-01-09  1776  
> 69f52adb Karsten Keil  2009-01-09  1777  static void
> 69f52adb Karsten Keil  2009-01-09  1778  deactivate_bchannel(struct bchannel *bch)
> 69f52adb Karsten Keil  2009-01-09  1779  {
> 69f52adb Karsten Keil  2009-01-09  1780  	struct hfcsusb *hw = bch->hw;
> 69f52adb Karsten Keil  2009-01-09  1781  	u_long flags;
> 69f52adb Karsten Keil  2009-01-09  1782  
> 69f52adb Karsten Keil  2009-01-09  1783  	if (bch->debug & DEBUG_HW)
> 69f52adb Karsten Keil  2009-01-09  1784  		printk(KERN_DEBUG "%s: %s: bch->nr(%i)\n",
> 69f52adb Karsten Keil  2009-01-09  1785  		       hw->name, __func__, bch->nr);
> 69f52adb Karsten Keil  2009-01-09  1786  
> 69f52adb Karsten Keil  2009-01-09  1787  	spin_lock_irqsave(&hw->lock, flags);
> fb286f04 Karsten Keil  2009-07-09 @1788  	mISDN_clear_bchannel(bch);
> 69f52adb Karsten Keil  2009-01-09  1789  	spin_unlock_irqrestore(&hw->lock, flags);
> 69f52adb Karsten Keil  2009-01-09  1790  	hfcsusb_setup_bch(bch, ISDN_P_NONE);
> 37952cfa Martin Bachem 2012-05-15  1791  	hfcsusb_stop_endpoint(hw, bch->nr - 1);
> 69f52adb Karsten Keil  2009-01-09  1792  }
> 69f52adb Karsten Keil  2009-01-09  1793  
> 69f52adb Karsten Keil  2009-01-09  1794  /*
> 69f52adb Karsten Keil  2009-01-09  1795   * Layer 1 B-channel hardware access
> 69f52adb Karsten Keil  2009-01-09  1796   */
> 69f52adb Karsten Keil  2009-01-09  1797  static int
> 69f52adb Karsten Keil  2009-01-09  1798  hfc_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg)
> 69f52adb Karsten Keil  2009-01-09  1799  {
> 69f52adb Karsten Keil  2009-01-09  1800  	struct bchannel	*bch = container_of(ch, struct bchannel, ch);
> 69f52adb Karsten Keil  2009-01-09  1801  	int		ret = -EINVAL;
> 69f52adb Karsten Keil  2009-01-09  1802  
> 69f52adb Karsten Keil  2009-01-09  1803  	if (bch->debug & DEBUG_HW)
> 69f52adb Karsten Keil  2009-01-09  1804  		printk(KERN_DEBUG "%s: cmd:%x %p\n", __func__, cmd, arg);
> 69f52adb Karsten Keil  2009-01-09  1805  
> 69f52adb Karsten Keil  2009-01-09  1806  	switch (cmd) {
> 69f52adb Karsten Keil  2009-01-09  1807  	case HW_TESTRX_RAW:
> 69f52adb Karsten Keil  2009-01-09  1808  	case HW_TESTRX_HDLC:
> 69f52adb Karsten Keil  2009-01-09  1809  	case HW_TESTRX_OFF:
> 69f52adb Karsten Keil  2009-01-09  1810  		ret = -EINVAL;
> 69f52adb Karsten Keil  2009-01-09  1811  		break;
> 69f52adb Karsten Keil  2009-01-09  1812  
> 69f52adb Karsten Keil  2009-01-09  1813  	case CLOSE_CHANNEL:
> 69f52adb Karsten Keil  2009-01-09  1814  		test_and_clear_bit(FLG_OPEN, &bch->Flags);
> 69f52adb Karsten Keil  2009-01-09  1815  		deactivate_bchannel(bch);
> 69f52adb Karsten Keil  2009-01-09  1816  		ch->protocol = ISDN_P_NONE;
> 69f52adb Karsten Keil  2009-01-09  1817  		ch->peer = NULL;
> 69f52adb Karsten Keil  2009-01-09  1818  		module_put(THIS_MODULE);
> 69f52adb Karsten Keil  2009-01-09  1819  		ret = 0;
> 69f52adb Karsten Keil  2009-01-09  1820  		break;
> 69f52adb Karsten Keil  2009-01-09  1821  	case CONTROL_CHANNEL:
> 69f52adb Karsten Keil  2009-01-09  1822  		ret = channel_bctrl(bch, arg);
> 69f52adb Karsten Keil  2009-01-09  1823  		break;
> 69f52adb Karsten Keil  2009-01-09  1824  	default:
> 69f52adb Karsten Keil  2009-01-09  1825  		printk(KERN_WARNING "%s: unknown prim(%x)\n",
> 69f52adb Karsten Keil  2009-01-09  1826  		       __func__, cmd);
> 69f52adb Karsten Keil  2009-01-09  1827  	}
> 69f52adb Karsten Keil  2009-01-09  1828  	return ret;
> 69f52adb Karsten Keil  2009-01-09  1829  }
> 69f52adb Karsten Keil  2009-01-09  1830  
> 69f52adb Karsten Keil  2009-01-09  1831  static int
> 69f52adb Karsten Keil  2009-01-09  1832  setup_instance(struct hfcsusb *hw, struct device *parent)
> 69f52adb Karsten Keil  2009-01-09  1833  {
> 69f52adb Karsten Keil  2009-01-09  1834  	u_long	flags;
> 69f52adb Karsten Keil  2009-01-09  1835  	int	err, i;
> 69f52adb Karsten Keil  2009-01-09  1836  
> 69f52adb Karsten Keil  2009-01-09  1837  	if (debug & DBG_HFC_CALL_TRACE)
> 69f52adb Karsten Keil  2009-01-09  1838  		printk(KERN_DEBUG "%s: %s\n", hw->name, __func__);
> 69f52adb Karsten Keil  2009-01-09  1839  
> 69f52adb Karsten Keil  2009-01-09  1840  	spin_lock_init(&hw->ctrl_lock);
> 69f52adb Karsten Keil  2009-01-09  1841  	spin_lock_init(&hw->lock);
> 69f52adb Karsten Keil  2009-01-09  1842  
> 69f52adb Karsten Keil  2009-01-09 @1843  	mISDN_initdchannel(&hw->dch, MAX_DFRAME_LEN_L1, ph_state);
> 69f52adb Karsten Keil  2009-01-09  1844  	hw->dch.debug = debug & 0xFFFF;
> 69f52adb Karsten Keil  2009-01-09  1845  	hw->dch.hw = hw;
> 69f52adb Karsten Keil  2009-01-09  1846  	hw->dch.dev.Dprotocols = (1 << ISDN_P_TE_S0) | (1 << ISDN_P_NT_S0);
> 69f52adb Karsten Keil  2009-01-09  1847  	hw->dch.dev.D.send = hfcusb_l2l1D;
> 69f52adb Karsten Keil  2009-01-09  1848  	hw->dch.dev.D.ctrl = hfc_dctrl;
> 69f52adb Karsten Keil  2009-01-09  1849  
> 69f52adb Karsten Keil  2009-01-09  1850  	/* enable E-Channel logging */
> 69f52adb Karsten Keil  2009-01-09  1851  	if (hw->fifos[HFCUSB_PCM_RX].pipe)
> 69f52adb Karsten Keil  2009-01-09 @1852  		mISDN_initdchannel(&hw->ech, MAX_DFRAME_LEN_L1, NULL);
> 69f52adb Karsten Keil  2009-01-09  1853  
> 69f52adb Karsten Keil  2009-01-09  1854  	hw->dch.dev.Bprotocols = (1 << (ISDN_P_B_RAW & ISDN_P_B_MASK)) |
> 69f52adb Karsten Keil  2009-01-09  1855  		(1 << (ISDN_P_B_HDLC & ISDN_P_B_MASK));
> 69f52adb Karsten Keil  2009-01-09  1856  	hw->dch.dev.nrbchan = 2;
> 69f52adb Karsten Keil  2009-01-09  1857  	for (i = 0; i < 2; i++) {
> 69f52adb Karsten Keil  2009-01-09  1858  		hw->bch[i].nr = i + 1;
> 69f52adb Karsten Keil  2009-01-09  1859  		set_channelmap(i + 1, hw->dch.dev.channelmap);
> 69f52adb Karsten Keil  2009-01-09  1860  		hw->bch[i].debug = debug;
> 034005a0 Karsten Keil  2012-05-15 @1861  		mISDN_initbchannel(&hw->bch[i], MAX_DATA_MEM, poll >> 1);
> 69f52adb Karsten Keil  2009-01-09  1862  		hw->bch[i].hw = hw;
> 69f52adb Karsten Keil  2009-01-09  1863  		hw->bch[i].ch.send = hfcusb_l2l1B;
> 69f52adb Karsten Keil  2009-01-09  1864  		hw->bch[i].ch.ctrl = hfc_bctrl;
> 69f52adb Karsten Keil  2009-01-09  1865  		hw->bch[i].ch.nr = i + 1;
> 69f52adb Karsten Keil  2009-01-09  1866  		list_add(&hw->bch[i].ch.list, &hw->dch.dev.bchannels);
> 69f52adb Karsten Keil  2009-01-09  1867  	}
> 69f52adb Karsten Keil  2009-01-09  1868  
> 69f52adb Karsten Keil  2009-01-09  1869  	hw->fifos[HFCUSB_B1_TX].bch = &hw->bch[0];
> 69f52adb Karsten Keil  2009-01-09  1870  	hw->fifos[HFCUSB_B1_RX].bch = &hw->bch[0];
> 69f52adb Karsten Keil  2009-01-09  1871  	hw->fifos[HFCUSB_B2_TX].bch = &hw->bch[1];
> 69f52adb Karsten Keil  2009-01-09  1872  	hw->fifos[HFCUSB_B2_RX].bch = &hw->bch[1];
> 69f52adb Karsten Keil  2009-01-09  1873  	hw->fifos[HFCUSB_D_TX].dch = &hw->dch;
> 69f52adb Karsten Keil  2009-01-09  1874  	hw->fifos[HFCUSB_D_RX].dch = &hw->dch;
> 69f52adb Karsten Keil  2009-01-09  1875  	hw->fifos[HFCUSB_PCM_RX].ech = &hw->ech;
> 69f52adb Karsten Keil  2009-01-09  1876  	hw->fifos[HFCUSB_PCM_TX].ech = &hw->ech;
> 69f52adb Karsten Keil  2009-01-09  1877  
> 69f52adb Karsten Keil  2009-01-09  1878  	err = setup_hfcsusb(hw);
> 69f52adb Karsten Keil  2009-01-09  1879  	if (err)
> 69f52adb Karsten Keil  2009-01-09  1880  		goto out;
> 69f52adb Karsten Keil  2009-01-09  1881  
> 69f52adb Karsten Keil  2009-01-09  1882  	snprintf(hw->name, MISDN_MAX_IDLEN - 1, "%s.%d", DRIVER_NAME,
> 69f52adb Karsten Keil  2009-01-09  1883  		 hfcsusb_cnt + 1);
> 69f52adb Karsten Keil  2009-01-09  1884  	printk(KERN_INFO "%s: registered as '%s'\n",
> 69f52adb Karsten Keil  2009-01-09  1885  	       DRIVER_NAME, hw->name);
> 69f52adb Karsten Keil  2009-01-09  1886  
> 69f52adb Karsten Keil  2009-01-09 @1887  	err = mISDN_register_device(&hw->dch.dev, parent, hw->name);
> 69f52adb Karsten Keil  2009-01-09  1888  	if (err)
> 69f52adb Karsten Keil  2009-01-09  1889  		goto out;
> 69f52adb Karsten Keil  2009-01-09  1890  
> 69f52adb Karsten Keil  2009-01-09  1891  	hfcsusb_cnt++;
> 69f52adb Karsten Keil  2009-01-09  1892  	write_lock_irqsave(&HFClock, flags);
> 69f52adb Karsten Keil  2009-01-09  1893  	list_add_tail(&hw->list, &HFClist);
> 69f52adb Karsten Keil  2009-01-09  1894  	write_unlock_irqrestore(&HFClock, flags);
> 69f52adb Karsten Keil  2009-01-09  1895  	return 0;
> 69f52adb Karsten Keil  2009-01-09  1896  
> 69f52adb Karsten Keil  2009-01-09  1897  out:
> 69f52adb Karsten Keil  2009-01-09  1898  	mISDN_freebchannel(&hw->bch[1]);
> 69f52adb Karsten Keil  2009-01-09  1899  	mISDN_freebchannel(&hw->bch[0]);
> 69f52adb Karsten Keil  2009-01-09  1900  	mISDN_freedchannel(&hw->dch);
> 69f52adb Karsten Keil  2009-01-09  1901  	kfree(hw);
> 69f52adb Karsten Keil  2009-01-09  1902  	return err;
> 69f52adb Karsten Keil  2009-01-09  1903  }
> 69f52adb Karsten Keil  2009-01-09  1904  
>
> :::::: The code at line 1757 was first introduced by commit
> :::::: 69f52adb2d534afc41fcc658f155e01f0b322f9e mISDN: Add HFC USB driver
>
> :::::: TO: Karsten Keil <kkeil@suse.de>
> :::::: CC: Karsten Keil <kkeil@suse.de>
>
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 34d9e9ce97c2..928cd073a657 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -416,8 +416,9 @@  endif
 $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
 	$(call if_changed_rule,as_o_S)
 
-targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
-targets += $(extra-y) $(MAKECMDGOALS) $(always)
+targets += $(filter-out $(subdir-obj-y), $(real-obj-y))
+targets += $(filter-out $(subdir-obj-m), $(real-obj-m))
+targets += $(lib-y) $(extra-y) $(MAKECMDGOALS) $(always)
 
 # Linker scripts preprocessor (.lds.S -> .lds)
 # ---------------------------------------------------------------------------
@@ -441,7 +442,7 @@  $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
 # ---------------------------------------------------------------------------
 
 # To build objects in subdirs, we need to descend into the directories
-$(sort $(subdir-obj-y)): $(subdir-ym) ;
+$(sort $(subdir-obj-y) $(subdir-obj-m)): $(subdir-ym) ;
 
 #
 # Rule to compile a set of .o files into one .o file
@@ -521,16 +522,16 @@  link_multi_deps =                     \
 $(filter $(addprefix $(obj)/,         \
 $($(subst $(obj)/,,$(@:.o=-objs)))    \
 $($(subst $(obj)/,,$(@:.o=-y)))       \
-$($(subst $(obj)/,,$(@:.o=-m)))), $^)
+$($(subst $(obj)/,,$(@:.o=-m)))), $(patsubst %/mod.a,%/,$^))
 
 quiet_cmd_link_multi-m = LD [M]  $@
-cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
+cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(patsubst %/, --whole-archive %/mod.a --no-whole-archive ,$(link_multi_deps)) $(cmd_secanalysis)
 
 $(multi-used-m): FORCE
 	$(call if_changed,link_multi-m)
-	@{ echo $(@:.o=.ko); echo $(link_multi_deps); \
+	@{ echo $(@:.o=.ko); echo $(patsubst %/,%/mod.a,$(link_multi_deps)); \
 	   $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
-$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
+$(call multi_depend, $(multi-used-m), .o, -objs -y -m,mod.a)
 
 targets += $(multi-used-m)
 targets := $(filter-out $(PHONY), $(targets))
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index ddfdd5cf47cd..6e7aa08324f0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -12,6 +12,13 @@  KBUILD_CFLAGS += $(subdir-ccflags-y)
 # Figure out what we need to build from the various variables
 # ===========================================================================
 
+# Directories in obj-m only cause that directory to be descended, which
+# is exactly what happens for directories in obj-y. So move all
+# directories from obj-m to obj-y.  Then we will know that any directory
+# in real-obj-m is a component of some other object.
+obj-y := $(obj-y) $(filter %/, $(obj-m))
+obj-m := $(filter-out %/, $(obj-m))
+
 # When an object is listed to be built compiled-in and modular,
 # only build the compiled-in version
 obj-m := $(filter-out $(obj-y),$(obj-m))
@@ -40,14 +47,14 @@  real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))
 # ---------------------------------------------------------------------------
 # o if we encounter foo/ in $(real-obj-y), replace it by foo/built-in.a
 #   and add the directory to the list of dirs to descend into: $(subdir-y)
-# o if we encounter foo/ in $(real-obj-m), remove it from $(real-obj-m)
+# o if we encounter foo/ in $(real-obj-m), replace it by foo/mod.a
 #   and add the directory to the list of dirs to descend into: $(subdir-m)
 __subdir-y	:= $(patsubst %/,%,$(filter %/, $(real-obj-y)))
 subdir-y	+= $(__subdir-y)
 __subdir-m	:= $(patsubst %/,%,$(filter %/, $(real-obj-m)))
 subdir-m	+= $(__subdir-m)
 real-obj-y	:= $(patsubst %/, %/built-in.a, $(real-obj-y))
-real-obj-m	:= $(filter-out %/, $(real-obj-m))
+real-obj-m	:= $(patsubst %/, %/mod.a, $(real-obj-m))
 
 # Subdirectories we need to descend into
 subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
@@ -55,6 +62,9 @@  subdir-ym	:= $(sort $(subdir-y) $(subdir-m))
 # $(subdir-obj-y) is the list of objects in $(real-obj-y) which uses dir/ to
 # tell kbuild to descend
 subdir-obj-y := $(filter %/built-in.a, $(real-obj-y))
+# $(subdir-obj-m) is the list of objects in $(real-obj-m) which uses dir/ to
+# tell kbuild to descend
+subdir-obj-m := $(filter %/mod.a, $(real-obj-m))
 
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
@@ -70,6 +80,7 @@  modorder	:= $(addprefix $(obj)/,$(modorder))
 obj-m		:= $(addprefix $(obj)/,$(obj-m))
 lib-y		:= $(addprefix $(obj)/,$(lib-y))
 subdir-obj-y	:= $(addprefix $(obj)/,$(subdir-obj-y))
+subdir-obj-m	:= $(addprefix $(obj)/,$(subdir-obj-m))
 real-obj-y	:= $(addprefix $(obj)/,$(real-obj-y))
 real-obj-m	:= $(addprefix $(obj)/,$(real-obj-m))
 single-used-m	:= $(addprefix $(obj)/,$(single-used-m))
@@ -172,11 +183,11 @@  dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
 
 # Useful for describing the dependency of composite objects
 # Usage:
-#   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
+#   $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add, object_in_directories)
 define multi_depend
 $(foreach m, $(notdir $1), \
 	$(eval $(obj)/$m: \
-	$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
+	$(addprefix $(obj)/, $(patsubst %/,%/$4,$(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))))
 endef
 
 # LEX