Skip to content

Commit

Permalink
ide-floppy: move /proc handling to ide-floppy_proc.c (take 2)
Browse files Browse the repository at this point in the history
While at it:
- idefloppy_capacity() -> ide_floppy_capacity()
- idefloppy_proc[] -> ide_floppy_proc[]
- idefloppy_settings[] -> ide_floppy_settings[]

v2:
Build fix for CONFIG_IDE_PROC_FS=n from Elias Oltmanns.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
Bartlomiej Zolnierkiewicz committed Oct 13, 2008
1 parent 5bb1536 commit b9103da
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 37 deletions.
4 changes: 4 additions & 0 deletions drivers/ide/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o
ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o
ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o

ifeq ($(CONFIG_IDE_PROC_FS), y)
ide-floppy_mod-y += ide-floppy_proc.o
endif

obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o
obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o
obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o
Expand Down
41 changes: 4 additions & 37 deletions drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,29 +552,14 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
return rc;
}

static sector_t idefloppy_capacity(ide_drive_t *drive)
sector_t ide_floppy_capacity(ide_drive_t *drive)
{
idefloppy_floppy_t *floppy = drive->driver_data;
unsigned long capacity = floppy->blocks * floppy->bs_factor;

return capacity;
}

#ifdef CONFIG_IDE_PROC_FS
ide_devset_rw_field(bios_cyl, bios_cyl);
ide_devset_rw_field(bios_head, bios_head);
ide_devset_rw_field(bios_sect, bios_sect);
ide_devset_rw_field(ticks, pc_delay);

static const struct ide_proc_devset idefloppy_settings[] = {
IDE_PROC_DEVSET(bios_cyl, 0, 1023),
IDE_PROC_DEVSET(bios_head, 0, 255),
IDE_PROC_DEVSET(bios_sect, 0, 63),
IDE_PROC_DEVSET(ticks, 0, 255),
{ 0 },
};
#endif

static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
{
u16 *id = drive->id;
Expand Down Expand Up @@ -639,24 +624,6 @@ static void idefloppy_cleanup_obj(struct kref *kref)
kfree(floppy);
}

#ifdef CONFIG_IDE_PROC_FS
static int proc_idefloppy_read_capacity(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
ide_drive_t*drive = (ide_drive_t *)data;
int len;

len = sprintf(page, "%llu\n", (long long)idefloppy_capacity(drive));
PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
}

static ide_proc_entry_t idefloppy_proc[] = {
{ "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL },
{ "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
{ NULL, 0, NULL, NULL }
};
#endif /* CONFIG_IDE_PROC_FS */

static int ide_floppy_probe(ide_drive_t *);

static ide_driver_t idefloppy_driver = {
Expand All @@ -672,8 +639,8 @@ static ide_driver_t idefloppy_driver = {
.end_request = idefloppy_end_request,
.error = __ide_error,
#ifdef CONFIG_IDE_PROC_FS
.proc = idefloppy_proc,
.settings = idefloppy_settings,
.proc = ide_floppy_proc,
.settings = ide_floppy_settings,
#endif
};

Expand Down Expand Up @@ -784,7 +751,7 @@ static int idefloppy_media_changed(struct gendisk *disk)
static int idefloppy_revalidate_disk(struct gendisk *disk)
{
struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
set_capacity(disk, idefloppy_capacity(floppy->drive));
set_capacity(disk, ide_floppy_capacity(floppy->drive));
return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions drivers/ide/ide-floppy.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ typedef struct ide_floppy_obj {
/* ide-floppy.c */
void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);
sector_t ide_floppy_capacity(ide_drive_t *);

/* ide-floppy_ioctl.c */
int ide_floppy_ioctl(struct inode *, struct file *, unsigned, unsigned long);

#ifdef CONFIG_IDE_PROC_FS
/* ide-floppy_proc.c */
extern ide_proc_entry_t ide_floppy_proc[];
extern const struct ide_proc_devset ide_floppy_settings[];
#endif

#endif /*__IDE_FLOPPY_H */
33 changes: 33 additions & 0 deletions drivers/ide/ide-floppy_proc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <linux/kernel.h>
#include <linux/ide.h>

#include "ide-floppy.h"

static int proc_idefloppy_read_capacity(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
ide_drive_t*drive = (ide_drive_t *)data;
int len;

len = sprintf(page, "%llu\n", (long long)ide_floppy_capacity(drive));
PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
}

ide_proc_entry_t ide_floppy_proc[] = {
{ "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL },
{ "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
{ NULL, 0, NULL, NULL }
};

ide_devset_rw_field(bios_cyl, bios_cyl);
ide_devset_rw_field(bios_head, bios_head);
ide_devset_rw_field(bios_sect, bios_sect);
ide_devset_rw_field(ticks, pc_delay);

const struct ide_proc_devset ide_floppy_settings[] = {
IDE_PROC_DEVSET(bios_cyl, 0, 1023),
IDE_PROC_DEVSET(bios_head, 0, 255),
IDE_PROC_DEVSET(bios_sect, 0, 63),
IDE_PROC_DEVSET(ticks, 0, 255),
{ 0 },
};

0 comments on commit b9103da

Please sign in to comment.