From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1769C433FE for ; Tue, 5 Oct 2021 01:31:09 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 143B561406 for ; Tue, 5 Oct 2021 01:31:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 143B561406 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DF75C80944; Tue, 5 Oct 2021 03:31:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kb9c/z4Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1652180641; Tue, 5 Oct 2021 03:31:03 +0200 (CEST) Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7E16580185 for ; Tue, 5 Oct 2021 03:30:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1029.google.com with SMTP id ls18so2739557pjb.3 for ; Mon, 04 Oct 2021 18:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=aMJA5EkVMDEY5+PlFvcgVfxgtU6qYVZ0NAdqUB447HQ=; b=kb9c/z4Q/N0adIp5X6+qjuSfTpBvwpYiHKH7DzDVzzMX2AfHsNRPYZu02QbZxrOUOF 5J7N/b8WiA7g6jLwvOlr0ucSchMD7fewcv5XyciKhl0xIoTk+x7LWEFxvP/nG5hMqot1 LKYe9IIn5YnSwUYStuH2hdDTFdOw2Al6CoM5FhsaJ0yYj9VKV8hznzcAOsS1U+fEQCFh 0/nxbJ/7DD4lBTfvYD/O5l/Tbw5i11AhKL5Q3N8uuy2BJTAYiOCb2+f9fHk3HmZzpd7R 9hfAdDJUGR/tm/HxH0kGsYA330Wsx7sj5+xGHTR0CFG1xd9skbgBue/1++5RKO2eXtLA QCsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=aMJA5EkVMDEY5+PlFvcgVfxgtU6qYVZ0NAdqUB447HQ=; b=pA97hrE/RX+04NGy078eK/qWUW0Ad4gyiOiE9+HJs+CkkMmAFQGstFlTQQAhAnqKUJ tJznrrAK5YHpIpUPNQXlvnccvfA8PsPrE51qj1D7zSW8BjCBL+cViM3tSYMVLm1MhndT 7uvMCfDP78lDuYYKc/LihNvFJo6lMtYffBQZf9RzHWQLYkUnA4SvWPQC+vEMWoWzQxgD 1UBwfjaQ4C7XOk31InJSPPiVM3+3hQT/F3SydI2vDk/UueVABLwE4YDwydAp9TbdDXq8 124pKhw9mKrLh2r0/+h942w7rnXinakq+OwLHy05uV8+3nf04w27pl5AwZMViQvuCgSA WaSA== X-Gm-Message-State: AOAM530KPLk0kvEbE42ad4FR3mCT4F2z4g+mYBJ2c/lTOaDfnIR2Z9AL fNDy63YOwUbpAsNpw5eCdLgwAg== X-Google-Smtp-Source: ABdhPJw5uGeBtPQ2MqIpUrI+sim1L4PepmSHvWZh0SqZMAvvP/45rfI3LtySOhi0M3QZ8XEtZkHT5w== X-Received: by 2002:a17:902:8543:b029:12d:461f:a6a8 with SMTP id d3-20020a1709028543b029012d461fa6a8mr2608047plo.1.1633397456562; Mon, 04 Oct 2021 18:30:56 -0700 (PDT) Received: from laputa (122-100-26-39m5.mineo.jp. [122.100.26.39]) by smtp.gmail.com with ESMTPSA id h8sm92397pjz.43.2021.10.04.18.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Oct 2021 18:30:56 -0700 (PDT) Date: Tue, 5 Oct 2021 10:30:45 +0900 From: AKASHI Takahiro To: Ilias Apalodimas Cc: xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, u-boot@lists.denx.de Subject: Re: [resent RFC 08/22] dm: blk: add UCLASS_PARTITION Message-ID: <20211005013045.GB39521@laputa> Mail-Followup-To: AKASHI Takahiro , Ilias Apalodimas , xypron.glpk@gmx.de, agraf@csgraf.de, sjg@chromium.org, u-boot@lists.denx.de References: <20211004034430.41355-1-takahiro.akashi@linaro.org> <20211004034430.41355-9-takahiro.akashi@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Mon, Oct 04, 2021 at 09:40:21PM +0300, Ilias Apalodimas wrote: > Hi Akashi-san, > > > > > [...] > > > +int blk_create_partitions(struct udevice *parent) > > +{ > > + int part, count; > > + struct blk_desc *desc = dev_get_uclass_plat(parent); > > + struct disk_partition info; > > + struct disk_part *part_data; > > + char devname[32]; > > + struct udevice *dev; > > + int ret; > > + > > + if (!CONFIG_IS_ENABLED(PARTITIONS) || > > + !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE)) > > + return 0; > > Would it make more sense to return an error here? !CONFIG_IS_ENABLED(PARTITIONS) means that a user doesn't want to use partitions on their system. So simply returning 0 would be fine, I think. This is kinda equivalence at the caller site: if (CONFIG_IS_ENABLED(PARTITIONS) && CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE)) ret = blk_create_partitions(dev); else debug("We don't care about partitions."); > > + > > + /* Add devices for each partition */ > > + for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) { > > + if (part_get_info(desc, part, &info)) > > + continue; > > + snprintf(devname, sizeof(devname), "%s:%d", parent->name, > > + part); > > + > > + ret = device_bind_driver(parent, "blk_partition", > > + strdup(devname), &dev); > > + if (ret) > > + return ret; > > + > > + part_data = dev_get_uclass_plat(dev); > > + part_data->partnum = part; > > + part_data->gpt_part_info = info; > > + count++; > > + > > + device_probe(dev); > > Probe can fail. Theoretically, yes. But as a matter of fact, device_probe() does almost nothing for UCLASS_PARTITION devices under the proposed implementation here and I don't expect it will ever fail. Please note that, as I commented in blk_part_post_probe(), we may want to call blk_create_partitions() in the future so that we will support "nested" partitioning in a partition :) -Takahiro Akashi > > + } > > + debug("%s: %d partitions found in %s\n", __func__, count, parent->name); > > + > > + return 0; > > +} > > + > > static int blk_post_probe(struct udevice *dev) > > { > > if (IS_ENABLED(CONFIG_PARTITIONS) && > > @@ -713,3 +752,75 @@ UCLASS_DRIVER(blk) = { > > .post_probe = blk_post_probe, > > .per_device_plat_auto = sizeof(struct blk_desc), > > }; > [...] > > Regards > /Ilias