19 Jan, 2016
1 commit
-
Back in the day we used to just say this code was root only so it was
ok that the bounds checking was sloppy. These days it annoys static
checkers so we fix it.In the original code "c > INT_MAX" was never true since "c" was an int.
I am not sure what was intended so I left it alone. But because I made
"c" unsigned it means we don't have a warning any more.The second warning is that we cap "i" but allow negatives leading to an
underflow of the ide_disks_chs[] array. The third set of warnings is
because these values come from the user and we cap most of the upper
bounds but allow negative values. Negative cylinders doesn't make
sense.drivers/ide/ide.c:262 ide_set_disk_chs() warn: impossible condition '(c > ((~0 >> 1))) => (s32min-s32max > s32max)'
drivers/ide/ide.c:270 ide_set_disk_chs() warn: check 'ide_disks_chs[i]' for negative offsets 'i' = s32min. extra = 's32min-19'
drivers/ide/ide.c:271 ide_set_disk_chs() warn: no lower bound on 'h'Signed-off-by: Dan Carpenter
Signed-off-by: David S. Miller
28 May, 2015
1 commit
-
Most code already uses consts for the struct kernel_param_ops,
sweep the kernel for the last offending stragglers. Other than
include/linux/moduleparam.h and kernel/params.c all other changes
were generated with the following Coccinelle SmPL patch. Merge
conflicts between trees can be handled with Coccinelle.In the future git could get Coccinelle merge support to deal with
patch --> fail --> grammar --> Coccinelle --> new patch conflicts
automatically for us on patches where the grammar is available and
the patch is of high confidence. Consider this a feature request.Test compiled on x86_64 against:
* allnoconfig
* allmodconfig
* allyesconfig@ const_found @
identifier ops;
@@const struct kernel_param_ops ops = {
};@ const_not_found depends on !const_found @
identifier ops;
@@-struct kernel_param_ops ops = {
+const struct kernel_param_ops ops = {
};Generated-by: Coccinelle SmPL
Cc: Rusty Russell
Cc: Junio C Hamano
Cc: Andrew Morton
Cc: Kees Cook
Cc: Tejun Heo
Cc: Ingo Molnar
Cc: cocci@systeme.lip6.fr
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Luis R. Rodriguez
Signed-off-by: Rusty Russell
13 Dec, 2014
1 commit
-
The module_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring
Signed-off-by: David S. Miller
17 Oct, 2013
1 commit
-
The dev_attrs field of struct bus_type is going away soon, dev_groups
should be used instead. This converts the ide bus code to use the
correct field.Acked-by: David S. Miller
Cc:
Signed-off-by: Greg Kroah-Hartman
11 Aug, 2010
1 commit
-
It has the additional benefit of typechecking (in this case, an unsigned int).
Signed-off-by: Rusty Russell
Reviewed-by: Takashi Iwai
30 Mar, 2010
1 commit
-
…it slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
07 Jun, 2009
1 commit
-
From the perspective of most users of recent systems, disabling Host
Protected Area (HPA) can break vendor RAID formats, GPT partitions and
risks corrupting firmware or overwriting vendor system recovery tools.Unfortunately the original (kernels < 2.6.30) behavior (unconditionally
disabling HPA and using full disk capacity) was introduced at the time
when the main use of HPA was to make the drive look small enough for the
BIOS to allow the system to boot with large capacity drives.Thus to allow the maximum compatibility with the existing setups (using
HPA and partitioned with HPA disabled) we automically disable HPA if
any partitions overlapping HPA are detected. Additionally HPA can also
be disabled using the "nohpa" module parameter (i.e. "ide_core.nohpa=0.0"
to disable HPA on /dev/hda).v2:
Fix ->resume HPA support.While at it:
- remove stale "idebus=" entry from Documentation/kernel-parameters.txtCc: Robert Hancock
Cc: Frans Pop
Cc: "Andries E. Brouwer"
Cc: Al Viro
Acked-by: Sergei Shtylyov
[patch description was based on input from Alan Cox and Frans Pop]
Emphatically-Acked-by: Alan Cox
Signed-off-by: Bartlomiej Zolnierkiewicz
25 Mar, 2009
2 commits
-
Remove stale comment from ide.c while at it.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
* ide_acpi_init() -> ide_acpi_init_port()
* ide_acpi_blacklist() -> ide_acpi_init()
* Call ide_acpi_init() only once (do it during IDE core
initialization) and cleanup the function accordingly.Signed-off-by: Bartlomiej Zolnierkiewicz
26 Feb, 2009
1 commit
-
Documentation/kernel-parameters.txt
- ide=nodma is no longer valid.drivers/ide/Kconfig
- The module is ide-core.ko not ide.drivers/ide/ide.c
- It took me a while to figure out what the arguments %d.%d:%d to nodma
module parameter ment, so I added a comment to each.
- Added a comment to each of the sscanf lines.
- There is a bug, if j is 0 it would previously clear all the other bits
except the current device, changed in three different places.
mask &= (1 << i) should be mask &= ~(1 << i).Signed-off-by: David Fries
[bart: s/disk/device/ in ide.c, beautify patch description]
Signed-off-by: Bartlomiej Zolnierkiewicz
07 Jan, 2009
7 commits
-
Add ide_port_for_each_dev() / ide_host_for_each_port() iterators
and update IDE code to use them.While at it:
- s/unit/i/ variable in ide_port_wait_ready(), ide_probe_port(),
ide_port_tune_devices(), ide_port_init_devices_data(), do_reset1(),
ide_acpi_set_state() and scc_dma_end()
- s/d/i/ variable in ide_proc_port_register_devices()There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
Allocate device structures dynamically instead of having them embedded
in ide_hwif_t:* Remove needless zeroing of port structure from ide_init_port_data().
* Add ide_hwif_t.devices[MAX_DRIVES] (table of pointers to the devices).
* Add ide_port_{alloc,free}_devices() helpers and use them respectively
in ide_{host,free}_alloc().* Convert all users of ->drives[] to use ->devices[] instead.
While at it:
* Use drive->dn for the slave device check in scc_pata.c.
As a nice side-effect this patch cuts ~1kB (x86-32) from the resulting
code size:text data bss dec hex filename
53963 1244 237 55444 d894 drivers/ide/ide-core.o.before
52981 1244 237 54462 d4be drivers/ide/ide-core.o.afterSigned-off-by: Bartlomiej Zolnierkiewicz
-
While at it:
- s/struct ide_driver_s/struct ide_driver/
- use to_ide_driver() macro in ide-proc.cSigned-off-by: Bartlomiej Zolnierkiewicz
-
* Move IDE_DEFAULT_MAX_FAILURES to .
* Move ide_cfg_mtx, ide_hwif_to_major[], ide_port_init_devices_data(),
ide_init_port_data(), ide_init_port_hw() and ide_unregister() to
ide-probe.c from ide.c.* Make ide_unregister(), ide_init_port_data(), ide_init_port_hw()
and ide_cfg_mtx static.While at it:
* Remove stale ide_init_port_data() documentation and ide_lock extern.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Merge ide_hwgroup_t with ide_hwif_t.
* Cleanup init_irq() accordingly, then remove no longer needed
ide_remove_port_from_hwgroup() and ide_ports[].* Remove now unused HWGROUP() macro.
While at it:
* ide_dump_ata_error() fixups
v2:
* Fix ->quirk_list check in do_ide_request()
(s/hwif->cur_dev/prev_port->cur_dev).Signed-off-by: Bartlomiej Zolnierkiewicz
-
Use hwif instead of hwgroup as {request,free}_irq()'s cookie,
teach ide_intr() to return early for non-active serialized ports,
modify unexpected_intr() accordingly and then use per-port IRQ
handlers instead of per-hwgroup ones.Signed-off-by: Bartlomiej Zolnierkiewicz
02 Jan, 2009
1 commit
-
While at it:
- media_string() -> ide_media_string()There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz
30 Dec, 2008
3 commits
-
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
Now that (almost) all host drivers have been fixed not to abuse ide_lock
and core code usage of ide_lock has been sanitized we may safely replace
ide_lock by per-hwgroup locks.This patch is partially based on earlier patch from Ravikiran G Thirumalai.
While at it:
- don't use deprecated HWIF() and HWGROUP() macros
- update locking documentation in ide.hv2:
Add missing spin_lock_init(&hwgroup->lock). (Noticed by Elias Oltmanns)Cc: Vaibhav V. Nivargi
Cc: Alok N. Kataria
Cc: Shai Fultheim
Signed-off-by: Ravikiran Thirumalai
Cc: Elias Oltmanns
Signed-off-by: Bartlomiej Zolnierkiewicz -
[ and ide_cfg_mtx mutex provides a sufficient protection for callers ]
Signed-off-by: Bartlomiej Zolnierkiewicz
14 Oct, 2008
9 commits
-
On user request (through sysfs), the IDLE IMMEDIATE command with UNLOAD
FEATURE as specified in ATA-7 is issued to the device and processing of
the request queue is stopped thereafter until the specified timeout
expires or user space asks to resume normal operation. This is supposed
to prevent the heads of a hard drive from accidentally crashing onto the
platter when a heavy shock is anticipated (like a falling laptop expected
to hit the floor). Port resets are deferred whenever a device on that
port is in the parked state.v3:
Elias Oltmanns wrote:
[...]
> >> 1. Make sure that no negative value is being passed to
> >> jiffies_to_msecs() in ide_park_show().
> >> 2. Drop the superfluous variable hwif in ide_special_rq().
> >> 3. Skip initialisation of task and tf in ide_special_rq() if we are not
> >> handling a (un)park request.
> >
> > Well, #3 should have been done differently because we donn't want to
> > check for REQ_(UN)?PARK_HEADS more often than is necessary.
>
> While preparing the backport to 2.6.27, it has just occurred to me that
> we need to clear the IDE_DFLAG_PARKED flag in ide_disk_pre_reset()
> because this flag must not be set after *any* sort of access to the
> device.v4:
Fix a memory leak due to a missing blk_put_request() in
issue_park_cmd(). Additionally, we should plug the queue when enqueueing
the unpark request because there is no guarantee that the park timeout
has not expired by then. Even though the chance for that to happen is
very slim, the request might end up hanging in the queue until the next
I/O operation is queued up. While at it, clean up the code a little:
- make issue_park_cmd() a function of type void since nobody cares for
the return value anyway;
- use blk_start_queueing() instead of __blk_run_queue() since we don't
have to worry about recursion;
- remove a superfluous pointer deference in task_no_data_intr().Signed-off-by: Elias Oltmanns
Cc: Jeff Garzik ,
Cc: Randy Dunlap
Cc: Tejun Heo
Signed-off-by: Bartlomiej Zolnierkiewicz -
Follow-up to commit 5c05ff68b9a9b40a9be949497e0aa980185565cf
("ide: switch to DMA-mapping API"):* pci_{alloc,free}_consistent() -> dma_{alloc,free}_coherent()
in ide_{allocate,release}_dma_engine().* Add ->prd_max_nents and ->prd_ent_size fields to ide_hwif_t
(+ set default values in ide_allocate_dma_engine()).* Make ide_{allocate,release}_dma_engine() available also
for CONFIG_BLK_DEV_IDEDMA_SFF=n. Then convert au1xxx-ide.c,
scc_pata.c and sgiioc4.c to use them.* Add missing ->init_dma method to scc_pata.
This patch also fixes:
- ->dmatable_cpu leak for au1xxx-ide
- too early realease of ->dmatable_cpu for scc_pata
- wrong amount of ->dmatable_cpu memory being freed for sgiioc4While at it:
- remove superfluous ->dma_base check from ide_unregister()
- return -ENOMEM on error in ide_release_dma_engine()
- beautify error message in ide_release_dma_engine()Signed-off-by: Bartlomiej Zolnierkiewicz
-
While at it:
- idedisk_ioctl() -> ide_disk_ioctl()Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Convert 'pio_mode' device setting to use DS_SYNC flag.
* Remove unused special_t.b.{set_tune,serviced} and ide_drive_t.tune_req.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Use 'drive->dn & 1' in ide_init_disk().
* remove [ata_]select_t.
While at it:
* Use ATA_DEVICE_OBS define in ide_port_init_devices_data().
Acked-by: Sergei Shtylyov
Signed-off-by: Bartlomiej Zolnierkiewicz -
* Call ide_port_init_devices() in ide_host_register()
also if 'struct ide_port_info *d' is not available.* Init drive->dn in ide_port_init_devices() instead of
ide_probe_port() so it is valid also in ->init_dev.* Pass device number to ide_dev_apply_params().
* Use 'drive->dn & 1' instead of drive->select.b.unit.
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Move ide*_pm_* enums from ide-io.c to .
* idedisk_pm_* -> ide_pm_*
* ide_pm_state_* -> ide_pm_*
* No need to set ide_pm_* enums to the fixed values.
* Uppercase ide_pm_* enums.
* Fix/update comments.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
Add 'unsigned long dev_flags' to ide_drive_t and convert bitfields
to IDE_DFLAG_* flags.While at it:
- IDE_DFLAG_ADDRESSING -> IDE_DFLAG_LBA48
- fixup some comments
- remove needless g->flags zeroing from ide*_probe()There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
ACPI _GTM / _PS0 / _STM were not called if only slave device was present.
Signed-off-by: Bartlomiej Zolnierkiewicz
11 Oct, 2008
10 commits
-
Use a special request for serialisation purposes and get rid of the
awkward ide_spin_wait_hwgroup(). This also involves converting the
ide_devset structure so it can be shared by the /proc and the ioctl code.Signed-off-by: Elias Oltmanns
[bart: use rq->cmd[] directly]
Signed-off-by: Bartlomiej Zolnierkiewicz -
* Move ioctls handling to ide-ioctls.c
(except HDIO_DRIVE_TASKFILE for now).* Make ide_{cmd,task}() static.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Fix intendation for the main 'switch ()'.
* 'switch ()' -> 'if ()' for HDIO_DRIVE_TASKFILE case.
* Move HDIO_SET_NICE case under HDIO_GET_NICE one.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Add struct ide_ioctl_devset representing ioctl device setting.
* Add ide_setting_ioctl() helper for matching given ioctl
and its parameters against table of ioctl device settings.* Convert ide_setting_ioctl() and idedisk_ioctl() to use
ide_setting_ioctl().* Un-export ide_setting_mtx.
While at it:
* {get,set}_lba_addressing() -> {get,set}_addressing()
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
It is always set to BUSSTATE_ON.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
Rename ide_id_to_hd_driveid() to ata_id_to_hd_driveid()
and move it to .Cc: Jeff Garzik
Signed-off-by: Bartlomiej Zolnierkiewicz -
Factor out HDIO_{GET,SET}_NICE ioctl handling from
generic_ide_ioctl() to ide_{get,set}_nice_ioctl().Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Use drive->media and drive->scsi to check if ->dsc_overlap
can be set by HDIO_SET_NICE ioctl in generic_ide_ioctl().* Remove unused ->supports_dsc_overlap field from ide_driver_t.
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz
-
Signed-off-by: Bartlomiej Zolnierkiewicz
-
* Add struct ide_devset, S_* flags, *DEVSET() & ide*_devset_*() macros.
* Add 'const struct ide_devset **settings' to ide_driver_t.
* Use 'const struct ide_devset **settings' in ide_drive_t instead of
'struct ide_settings_s *settings'. Then convert core code and device
drivers to use struct ide_devset and co.:- device settings are no longer allocated dynamically for each device
but instead there is an unique struct ide_devset instance per setting- device driver keeps the pointer to the table of pointers to its
settings in ide_driver_t.settings- generic settings are kept in ide_generic_setting[]
- ide_proc_[un]register_driver(), ide_find_setting_by_name(),
ide_{read,write}_setting() and proc_ide_{read,write}_settings()
are updated accordingly- ide*_add_settings() are removed
* Remove no longer used __ide_add_setting(), ide_add_setting(),
__ide_remove_setting() and auto_remove_settings().* Remove no longer used TYPE_*, SETTING_*, ide_procset_t
and ide_settings_t.* ->keep_settings, ->using_dma, ->unmask, ->noflush, ->dsc_overlap,
->nice1, ->addressing, ->wcache and ->nowerr ide_drive_t fields
can now be bitfield flags.While at it:
* Rename ide_find_setting_by_name() to ide_find_setting().
* Rename write_wcache() to set_wcache().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz