Musnad Ahmad, Hadith 767
Arabic text
حَدَّثَنَا يَحْيَى بْنُ آدَمَ، حَدَّثَنَا ابْنُ مُبَارَكٍ، عَنْ يَحْيَى بْنِ أَيُّوبَ، عَنْ عُبَيْدِ اللهِ بْنِ زَحْرٍ، عَنْ عَلِيِّ بْنِ يَزِيدَ، عَنِ الْقَاسِمِ، عَنْ أَبِي أُمَامَةَ، عَنْ عَلِيٍّ، قَالَ: كُنْتُ إِذَا اسْتَأْذَنْتُ عَلَى رَسُولِ اللهِ ﷺ إِنْ كَانَ فِي صَلاةٍ سَبَّحَ، وَإِنْ كَانَ غَيْرَ ذَلِكَ أَذِنَ .
Translation
I used to go to the Prophet (ﷺ) and ask permission to enter. If he was praying, he would say Subhan Allah, and if he was not praying, he would give me permission to enter.