Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2872165pxa; Tue, 25 Aug 2020 05:51:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBM4Odk4P3v5TLkoqtDEZInIeTvJy3v761irQecw0Mo/5eMI75OLPYtn3i0TBjWkpbBkaV X-Received: by 2002:aa7:cb56:: with SMTP id w22mr9794839edt.96.1598359885421; Tue, 25 Aug 2020 05:51:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598359885; cv=none; d=google.com; s=arc-20160816; b=lmXLoIsfun0FGRU0iaQg+KmTKdJ9b2ibm8UbG6SoMpeN0rs7aVwV4B89/Vsw0B1lHX RcdmDovAAcDb7BOxYZU1nimLpHl6nEywK1/ZXyrI1T+o3XXjDSI+0fCADtp7dXPy3Ad6 A8GlCrvCTdfInH3wKXWmZG8RIxLpTRODLKdrI3xRdxA9SRiCGOvgqJh4nV4EiwmXdCLY 6vYm86o1NoGSSH5lLLyQmLNOjfM6eTCOJ7ACW6Y8cIZs1u0gcLnm8IaMm7iVTsrW+8Sy e1DK0RmM1KVSL6cgfVFomp6BKgu0m3MvgYemAK36m8Rf6759KQL2fSYaHoAhs3BSXGP7 h/AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :ironport-sdr:dkim-signature:ironport-sdr; bh=XsnWCKWy7iVN38gFrjUIvYY5wRoWTVW/laPT82q7eC0=; b=Z+42mxQ6hqPY58Dk1h6djsSPByboO0pz9aTJulRNz1dJcLwiNZXoi80N39sfqlxMSf hnO2RisN6LHi7R5tPxHJ/Avkb8YVuaXnd/ca7ZBAnS3HfHnWQbX1hfblrIpdH488x3rG MbBrHPTFcvhHkGtLEVCY/bWBTasky6MLtzPdZZxdbUH2IPe/Iq1/48RjUC8cCcGfU4fj cDhEPHZTOaiWYOycjxxobIC+5tJaSaUWWBrSTiTVFHjK9W0Ot9//pfZlqPfdcBWg1A6s 6iihPd6CipuP8PzJ7hg55G+JENzgqtVqlQ6F911nEl3abxdWra/+itylY08gyhsxfwTw A+mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@tq-group.com header.s=key1 header.b=TFpFgGII; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y19si727565edt.53.2020.08.25.05.51.02; Tue, 25 Aug 2020 05:51:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@tq-group.com header.s=key1 header.b=TFpFgGII; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730032AbgHYMDV (ORCPT + 99 others); Tue, 25 Aug 2020 08:03:21 -0400 Received: from mx1.tq-group.com ([62.157.118.193]:61528 "EHLO mx1.tq-group.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728567AbgHYMBB (ORCPT ); Tue, 25 Aug 2020 08:01:01 -0400 IronPort-SDR: 6zdHpv3OdfV3hyh0EdskEu+UPLu/M69ZmFtzQKXZ1pCrVeU7JOR82StliBN4baJEAea/bJSd+5 F/2twTHqOfoeNmGl+BrodQTF2fpEriSycrhp/VM0Mgo5LKwRHCEPi55A1V6J4yL9M0+OpRkpq9 ulam5l+pqQpnHw9qrVop951qwBhIcSZZAA4pSQ9koMnuv6ht8UTmCPSnhCcwW+1yf73ZDsmYbM /0BvNI895j9fSvmD6y1EgnrG5lZ9Zi6pmz0G5FVvtBTkbvpwZ74jRDwLo9Zp8LRfb3hsWSn2rL qE8= X-IronPort-AV: E=Sophos;i="5.76,352,1592863200"; d="scan'208";a="13590046" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 25 Aug 2020 14:00:40 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Tue, 25 Aug 2020 14:00:40 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Tue, 25 Aug 2020 14:00:40 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1598356840; x=1629892840; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=8miJjHVFYc/bpyj6qBdQOmlSnWEp1x28yyZ2xAwXd7E=; b=TFpFgGIItZZ6Hfm9j+DSHG8urROrM04d6sXbAaGI11CpJC+CGjRuY2FN FVhKNCK9vRyd3ipqGaNKnvFPiYuBQwMQ/OEcgLhyUoojyLmkDCM6I+Psp pHxSg7PYV9L7xPqSZUDCj06dOiSkOZu9OIOw67XJdu0+J+cP/VNp9iDlF gyepLv9uKgaXiwg+iTl94HOO6Gt4c7Jsnkt9ql7YllOnZ48BIwTYLChQO 8Z78wvHiRWCDDS7mWU0HsIk0LflJhbMsH3lWU1xOuoqG/oi8Xkw7b1UIC Zs1+0PDC3jH+A1vW12qtYk+wJJ/E9LWOPij++EoBpQxd2YOPPn7X3kJgX g==; IronPort-SDR: 3ZUPXeoIoG8BMineYbSaOq103KqArpYZptsK7J8L/+d6BXHFTn08diiop2JaQ/kg+DYBuAIV0n vTV+IwTJoidgr6baurJmZgR3v4PEjLWIf9Z+Er3215Zmc3NRRywTQrnVDRoAN2loUfVBNztZLt bMBkmgdmjJTEQXQsCol1+JPuA10WP/tj9bomARTk5jINV5YdULrMfWQpOK/r56z5HIwSprcusO oCmsqYusVbOzIsgyuf+DpewTRRCw5/l/nbGmRTtXiYSPxkYLK7QHeZHkHJZ1hhfsLzUTVx/q6C yRQ= X-IronPort-AV: E=Sophos;i="5.76,352,1592863200"; d="scan'208";a="13590045" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 25 Aug 2020 14:00:40 +0200 Received: from schifferm-ubuntu4.tq-net.de (schifferm-ubuntu4.tq-net.de [10.117.49.26]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id 3DA40280065; Tue, 25 Aug 2020 14:00:40 +0200 (CEST) Message-ID: <11654b05dd8fb87e195aed20cbdaa22d8856b072.camel@ew.tq-group.com> Subject: Re: (EXT) Re: [PATCH mmc-next v2] mmc: allow setting slot index via device tree alias From: Matthias Schiffer To: Ulf Hansson Cc: Sascha Hauer , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List Date: Tue, 25 Aug 2020 14:00:38 +0200 In-Reply-To: <548605506aa2e73afafdc228263da04585871e0b.camel@ew.tq-group.com> References: <20200820075949.19133-1-matthias.schiffer@ew.tq-group.com> <548605506aa2e73afafdc228263da04585871e0b.camel@ew.tq-group.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-08-25 at 11:39 +0200, Matthias Schiffer wrote: > On Tue, 2020-08-25 at 11:14 +0200, Ulf Hansson wrote: > > On Thu, 20 Aug 2020 at 09:59, Matthias Schiffer > > wrote: > > > --- a/drivers/mmc/core/host.c > > > +++ b/drivers/mmc/core/host.c > > > @@ -387,6 +387,7 @@ struct mmc_host *mmc_alloc_host(int extra, > > > struct device *dev) > > > { > > > int err; > > > struct mmc_host *host; > > > + int alias_id, min_idx, max_idx; > > > > > > host = kzalloc(sizeof(struct mmc_host) + extra, > > > GFP_KERNEL); > > > if (!host) > > > @@ -395,7 +396,18 @@ struct mmc_host *mmc_alloc_host(int extra, > > > struct device *dev) > > > /* scanning will be enabled when we're ready */ > > > host->rescan_disable = 1; > > > > > > - err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL); > > > + host->parent = dev; > > > + > > > + alias_id = mmc_get_reserved_index(host); > > > + if (alias_id >= 0) { > > > + min_idx = alias_id; > > > + max_idx = alias_id + 1; > > > + } else { > > > + min_idx = mmc_first_nonreserved_index(); > > > + max_idx = 0; > > > + } > > > + > > > + err = ida_simple_get(&mmc_host_ida, min_idx, max_idx, > > > GFP_KERNEL); One more question I came across when reworking my patch: Do we need a fallback here for the case where the reserved index is already taken? To handle an SD card being replaced while still mounted? > > > if (err < 0) { > > > kfree(host); > > > return NULL; > > > @@ -406,7 +418,6 @@ struct mmc_host *mmc_alloc_host(int extra, > > > struct device *dev) > > > dev_set_name(&host->class_dev, "mmc%d", host->index); > > > host->ws = wakeup_source_register(NULL, dev_name(&host- > > > > class_dev)); > > > > > > - host->parent = dev; > > > host->class_dev.parent = dev; > > > host->class_dev.class = &mmc_host_class; > > > device_initialize(&host->class_dev); > > > -- > > > 2.17.1 > > > > > > > Kind regards > > Uffe