mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 10/13] Remove 'disk_drive.c' as it is now replaced by generic partition handling
Date: Tue, 22 Nov 2011 09:29:24 +0100	[thread overview]
Message-ID: <1321950567-13261-11-git-send-email-jbe@pengutronix.de> (raw)
In-Reply-To: <1321950567-13261-1-git-send-email-jbe@pengutronix.de>

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
---
 drivers/ata/Kconfig      |    8 --
 drivers/ata/Makefile     |    1 -
 drivers/ata/disk_drive.c |  247 ----------------------------------------------
 3 files changed, 0 insertions(+), 256 deletions(-)
 delete mode 100644 drivers/ata/disk_drive.c

diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index a85958c..86b5673 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -15,16 +15,8 @@ config DISK_WRITE
 
 comment "drive types"
 
-config DISK_DRIVE
-	bool "Generic disk drives"
-	help
-	  Add support for generic disk drives. Common behaviour for this kind
-	  of devices is using a partition table in the first sector. Say Y here
-	  if you intend to work with disk drives (also CF cards and SD cards).
-
 config DISK_BIOS
 	bool "BIOS based"
-	select DISK_DRIVE
 	depends on X86_BIOS_BRINGUP
 	help
 	  Gain disk drive access via int13 calls to the standard PC-BIOS.
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 10f3957..e2b41b7 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -1,6 +1,5 @@
 # drive types
 
-obj-$(CONFIG_DISK_DRIVE) += disk_drive.o
 obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
 
 # interface types
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
deleted file mode 100644
index c5c1ee9..0000000
--- a/drivers/ata/disk_drive.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2009 Juergen Beisert, Pengutronix
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-
-/**
- * @file
- * @brief Generic disk drive support
- *
- * @todo Support for disks larger than 4 GiB
- * @todo Reliable size detection for BIOS based disks (on x86 only)
- */
-
-#include <stdio.h>
-#include <init.h>
-#include <driver.h>
-#include <types.h>
-#include <ata.h>
-#include <xfuncs.h>
-#include <errno.h>
-#include <string.h>
-#include <linux/kernel.h>
-#include <malloc.h>
-#include <common.h>
-#include <block.h>
-#include <asm/unaligned.h>
-
-/**
- * Description of one partition table entry (D*S type)
- */
-struct partition_entry {
-	uint8_t boot_indicator;
-	uint8_t chs_begin[3];
-	uint8_t type;
-	uint8_t chs_end[3];
-	uint32_t partition_start;
-	uint32_t partition_size;
-} __attribute__ ((packed));
-
-/** one for all */
-#define SECTOR_SIZE 512
-
-/**
- * Guess the size of the disk, based on the partition table entries
- * @param dev device to create partitions for
- * @param table partition table
- * @return size in sectors
- */
-#ifdef CONFIG_DISK_BIOS
-static unsigned long disk_guess_size(struct device_d *dev, struct partition_entry *table)
-{
-	int part_order[4] = {0, 1, 2, 3};
-	unsigned long size = 0;
-	int i;
-
-	/* TODO order the partitions */
-
-	for (i = 0; i < 4; i++) {
-		if (table[part_order[i]].partition_start != 0) {
-			size += table[part_order[i]].partition_start - size; /* the gap */
-			size += table[part_order[i]].partition_size;
-		}
-	}
-#if 1
-/* limit disk sizes we can't handle due to 32 bit limits */
-	if (size > 0x7fffff) {
-		dev_warn(dev, "Warning: Size limited due to 32 bit contraints\n");
-		size = 0x7fffff;
-	}
-#endif
-	return size;
-}
-#endif
-
-/**
- * Register partitions found on the drive
- * @param dev device to create partitions for
- * @param table partition table
- * @return 0 on success
- */
-static int disk_register_partitions(struct device_d *dev, struct partition_entry *table)
-{
-	int part_order[4] = {0, 1, 2, 3};
-	int i, rc;
-	char drive_name[16], partition_name[19];
-	u32 partition_start, partition_size;
-
-	/* TODO order the partitions */
-
-	for (i = 0; i < 4; i++) {
-		partition_start = get_unaligned(&table[part_order[i]].partition_start);
-		partition_size  = get_unaligned(&table[part_order[i]].partition_size);
-
-		sprintf(drive_name, "%s%d", dev->name, dev->id);
-		sprintf(partition_name, "%s%d.%d", dev->name, dev->id, i);
-		if (partition_start != 0) {
-#if 1
-/* ignore partitions we can't handle due to 32 bit limits */
-			if (partition_start > 0x7fffff)
-				continue;
-			if (partition_size > 0x7fffff)
-				continue;
-#endif
-			dev_dbg(dev, "Registering partition %s to drive %s\n",
-				partition_name, drive_name);
-			rc = devfs_add_partition(drive_name,
-				partition_start * SECTOR_SIZE,
-				partition_size * SECTOR_SIZE,
-				DEVFS_PARTITION_FIXED, partition_name);
-			if (rc != 0)
-				dev_err(dev, "Failed to register partition %s (%d)\n", partition_name, rc);
-		}
-	}
-
-	return 0;
-}
-
-struct ata_block_device {
-	struct block_device blk;
-	struct device_d *dev;
-	struct ata_interface *intf;
-};
-
-static int atablk_read(struct block_device *blk, void *buf, int block,
-		int num_blocks)
-{
-	struct ata_block_device *atablk = container_of(blk, struct ata_block_device, blk);
-
-	return atablk->intf->read(atablk->dev, block, num_blocks, buf);
-}
-
-#ifdef CONFIG_DISK_WRITE
-static int atablk_write(struct block_device *blk, const void *buf, int block,
-		int num_blocks)
-{
-	struct ata_block_device *atablk = container_of(blk, struct ata_block_device, blk);
-
-	return atablk->intf->write(atablk->dev, block, num_blocks, buf);
-}
-#endif
-
-static struct block_device_ops ataops = {
-	.read = atablk_read,
-#ifdef CONFIG_DISK_WRITE
-	.write = atablk_write,
-#endif
-};
-
-/**
- * Probe the connected disk drive
- */
-static int disk_probe(struct device_d *dev)
-{
-	uint8_t *sector;
-	int rc;
-	struct ata_interface *intf = dev->platform_data;
-	struct ata_block_device *atablk = xzalloc(sizeof(*atablk));
-
-	sector = xmalloc(SECTOR_SIZE);
-
-	rc = intf->read(dev, 0, 1, sector);
-	if (rc != 0) {
-		dev_err(dev, "Cannot read MBR of this device\n");
-		rc = -ENODEV;
-		goto on_error;
-	}
-
-	/*
-	 * BIOS based disks needs special handling. Not the driver can
-	 * enumerate the hardware, the BIOS did it already. To show the user
-	 * the drive ordering must not correspond to the Linux drive order,
-	 * use the 'biosdisk' name instead.
-	 */
-#ifdef CONFIG_DISK_BIOS
-	if (strcmp(dev->driver->name, "biosdisk") == 0)
-		atablk->blk.cdev.name = asprintf("biosdisk%d", dev->id);
-	else
-#endif
-		atablk->blk.cdev.name = asprintf("disk%d", dev->id);
-
-#ifdef CONFIG_DISK_BIOS
-	/* On x86, BIOS based disks are coming without a valid .size field */
-	if (dev->resource[0].size == 0) {
-		/* guess the size of this drive if not otherwise given */
-		dev->resource[0].size = disk_guess_size(dev,
-			(struct partition_entry*)&sector[446]) * SECTOR_SIZE;
-		dev_info(dev, "Drive size guessed to %u kiB\n", dev->resource[0].size / 1024);
-	}
-#endif
-	atablk->blk.num_blocks = dev->resource[0].size / SECTOR_SIZE;
-	atablk->blk.ops = &ataops;
-	atablk->blk.blockbits = 9;
-	atablk->dev = dev;
-	atablk->intf = intf;
-	blockdevice_register(&atablk->blk);
-
-	if ((sector[510] != 0x55) || (sector[511] != 0xAA)) {
-		dev_info(dev, "No partition table found\n");
-		rc = 0;
-		goto on_error;
-	}
-
-
-	rc = disk_register_partitions(dev, (struct partition_entry*)&sector[446]);
-
-on_error:
-	free(sector);
-	return rc;
-}
-
-#ifdef CONFIG_DISK_BIOS
-static struct driver_d biosdisk_driver = {
-        .name   = "biosdisk",
-        .probe  = disk_probe,
-};
-#endif
-
-static struct driver_d disk_driver = {
-        .name   = "disk",
-        .probe  = disk_probe,
-};
-
-static int disk_init(void)
-{
-#ifdef CONFIG_DISK_BIOS
-	register_driver(&biosdisk_driver);
-#endif
-	register_driver(&disk_driver);
-	return 0;
-}
-
-device_initcall(disk_init);
-- 
1.7.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-11-22  8:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22  8:29 [PATCHv2] Rework of handling disk like media Juergen Beisert
2011-11-22  8:29 ` [PATCH 01/13] USB Mass Storage driver: Fix compile time warning Juergen Beisert
2011-11-22  8:29 ` [PATCH 02/13] Create a unique cdev number for on demand devices Juergen Beisert
2011-11-22  8:29 ` [PATCH 03/13] ATA/DISK: Add generic disk support when enabling the BIOS disk driver Juergen Beisert
2011-11-22  8:29 ` [PATCH 04/13] ATA/DISK: Enabling write support does not belong to 'drive types' Juergen Beisert
2011-11-22  8:29 ` [PATCH 05/13] ATA/DISK: Reorganize file structure and names for future updates Juergen Beisert
2011-11-22  8:29 ` [PATCH 06/13] ATA/DISK: The BIOS based disk driver is not an interface Juergen Beisert
2011-11-22  8:29 ` [PATCH 07/13] ATA/DISK: Share important constants and structures Juergen Beisert
2011-11-22  8:29 ` [PATCH 08/13] DISK: Add common partition handling for disk like media Juergen Beisert
2011-11-22  8:29 ` [PATCH 09/13] Use generic block layer to access the drives and do partition parsing Juergen Beisert
2011-11-22  8:29 ` Juergen Beisert [this message]
2011-11-22  8:29 ` [PATCH 11/13] ATA/DISK: Remove the now unused header <ata.h> Juergen Beisert
2011-11-22  8:29 ` [PATCH 12/13] ATA Disk Support: Add support for native ATA type drives Juergen Beisert
2011-11-22  8:29 ` [PATCH 13/13] Add driver for IDE like interfaces Juergen Beisert
  -- strict thread matches above, loose matches on Subject: below --
2011-11-24 12:43 [PATCHv3] Rework of handling disk like media Juergen Beisert
2011-11-24 12:43 ` [PATCH 10/13] Remove 'disk_drive.c' as it is now replaced by generic partition handling Juergen Beisert
2011-11-16  9:24 Rework of handling disk like media Juergen Beisert
2011-11-16  9:24 ` [PATCH 10/13] Remove 'disk_drive.c' as it is now replaced by generic partition handling Juergen Beisert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1321950567-13261-11-git-send-email-jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox